I have created the following responsive navigation bar with Tailwind and have a problem with the dropdown button ("Folgen") which shows the content always somewhere else on the x-axis than the button (depending on the window width).
How could I make sure that the dropdown always stays within the browser window (no overflow outside of the window) and stay close to the button depending on the browser width?
<nav class="bg-blue-800 shadow-lg sticky top-0 z-50 h-[3.75rem]">
<div class="max-w-6xl mx-auto px-4 h-[3.75rem]">
<div class="flex justify-between h-[3.75rem]">
<div class="flex space-x-7">
<div>
<!-- Website Logo -->
<a class="flex items-center py-4 px-2 text-white font-bold text-lg" href="<?= $site->url() ?>"><?= $site->title()->html() ?></a>
</a>
</div>
<!-- Primary Navbar items -->
<div class="hidden md:flex items-center space-x-1">
<?php foreach ($site->children()->listed() as $item): ?>
<a class="py-4 px-2 text-white font-semibold hover:text-white-500 hover:bg-blue-500 transition duration-300" <?php e($item->isOpen(), 'aria-current ') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a>
<?php endforeach ?>
</div>
</div>
<!-- This is a search component -->
<ul class="flex items-center ml-auto space-x-1">
<div class="md:flex hidden items-center ml-auto bg-blue-800 space-x-1 pr-4">
<form method="post" action="<?= page('search')->url() ?>">
<div class="relative text-gray-600 focus-within:text-gray-800">
<span class="absolute inset-y-0 left-0 flex items-center pl-2">
<button type="submit" class="p-1 focus:outline-none focus:shadow-outline">
<svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" class="w-6 h-6"><path d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>
</button>
</span>
<input type="search" name="q" class="py-2 text-sm text-gray-900 bg-white rounded-md pl-10 focus:outline-none focus:bg-white focus:text-gray-900" placeholder="Suche..." value="<?php echo (!empty($query)) ? esc($query) : '' ?>" autocomplete="off">
</div>
</form>
</div>
<!-- Language selector -->
<?php foreach($kirby->languages()->not($kirby->language()) as $language): ?>
<?php if ($page->translation($language->code())->exists()): ?>
<?= svg('assets/icons/OOjs_UI_icon_language-ltr-invert.svg') ?>
<li <?php e($kirby->language() == $language, ' class="active text-white"') ?>>
<a href="<?= $page->url($language->code()) ?>" hreflang="<?php echo $language->code() ?>" class="text-white">
<?= html($language->name()) ?>
</a>
</li>
<?php endif ?>
<?php endforeach ?>
</ul>
<!-- Social Navbar items -->
<div class="group hidden md:flex">
<button
class="outline-none focus:outline-none px-3 py-1 bg-blue-800 text-white rounded-sm flex items-center min-w-32"
>
<span class="pr-1 font-semibold flex-1">Folgen</span>
<span>
<svg
class="fill-current h-4 w-4 transform group-hover:-rotate-180
transition duration-150 ease-in-out"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
>
<path
d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"
/>
</svg>
</span>
</button>
<ul
class="bg-gray-200 inline-flex transform scale-0 group-hover:scale-100 absolute transition duration-150 ease-in-out origin-top top-full right-0 left-auto"
>
<li class="items-center inline-flex py-2"><?php snippet('social') ?></li>
</ul>
</div>
<!-- Mobile menu button -->
<div class="md:hidden flex ml-4 items-center">
<button class="outline-none mobile-menu-button" aria-label="Navigation icon">
<svg class=" w-7 h-7 text-white hover:text-blue-500 "
x-show="!showMenu"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path d="M4 6h16M4 12h16M4 18h16"></path>
</svg>
</button>
</div>
</div>
</div>
<!-- mobile menu -->
<div class="hidden mobile-menu text-center bg-blue-600">
<ul class="inline-block">
<?php foreach ($site->children()->listed() as $item): ?>
<li><a class="block px-2 py-4 text-white hover:bg-blue-500 transition duration-300" <?php e($item->isOpen(), 'aria-current ') ?> href="<?= $item->url() ?>"><?= $item->title()->html() ?></a></li>
<?php endforeach ?>
<div class="inline-flex px-2 py-4">
<form method="post" action="<?= page('search')->url() ?>">
<div class="relative text-gray-600 focus-within:text-gray-800">
<span class="absolute inset-y-0 left-0 flex items-center pl-2">
<button type="submit" class="p-1 focus:outline-none focus:shadow-outline">
<svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" class="w-6 h-6"><path d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>
</button>
</span>
<input type="search" name="q" class="py-2 text-sm text-gray-900 bg-white rounded-md pl-10 focus:outline-none focus:bg-white focus:text-gray-900" placeholder="Suche..." value="<?php echo (!empty($query)) ? esc($query) : '' ?>">
</div>
</form>
</div>
<div class="inline-flex px-2 py-4 text-white filter invert"><?php snippet('social') ?></div>
</ul>
</div>
<script>
const btn = document.querySelector("button.mobile-menu-button");
const menu = document.querySelector(".mobile-menu");
btn.addEventListener("click", () => {
menu.classList.toggle("hidden");
});
</script>
</nav>
You can find a working example over here.
You can add relative class on the container which contains the button and the dropdown. Your dropdown, which has the right-0 class, will then be positioned on the right edge of the container instead of the browser window like it is now. Working example here.
Related
I'm using tailwind with cdn, and just copy pasting one of the dropdown lists on flowbite:
<button id="dropdownDefault" data-dropdown-toggle="dropdown" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2.5 text-center inline-flex items-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" type="button">Dropdown button <svg class="ml-2 w-4 h-4" aria-hidden="true" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg></button>
<!-- Dropdown menu -->
<div id="dropdown" class="z-10 w-44 bg-white rounded divide-y divide-gray-100 shadow dark:bg-gray-700 block" data-popper-reference-hidden="" data-popper-escaped="" data-popper-placement="bottom" style="position: absolute; inset: 0px auto auto 0px; margin: 0px; transform: translate3d(327px, 70px, 0px);">
<ul class="py-1 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownDefault">
<li>
Dashboard
</li>
<li>
Settings
</li>
<li>
Earnings
</li>
<li>
Sign out
</li>
</ul>
</div>
But this is what I'm getting:
Any idea what could be causing this?
you need to include the FlowBite <script> before the end of the body element
also, require the minified stylesheet inside the <head> tag like this :
<head>
<link rel="stylesheet" href="https://unpkg.com/flowbite#1.5.1/dist/flowbite.min.css" />
</head>
<body>
<button id="dropdownDefault" data-dropdown-toggle="dropdown" class="inline-flex items-center rounded-lg bg-blue-700 px-4 py-2.5 text-center text-sm font-medium text-white hover:bg-blue-800 focus:outline-none focus:ring-4 focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" type="button">
Dropdown busdatton <svg class="ml-2 h-4 w-4" aria-hidden="true" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
<!-- Dropdown menu -->
<div id="dropdown" class="z-10 block w-44 divide-y divide-gray-100 rounded bg-white shadow dark:bg-gray-700" data-popper-reference-hidden="" data-popper-escaped="" data-popper-placement="bottom" style="position: absolute; inset: 0px auto auto 0px; margin: 0px; transform: translate3d(327px, 70px, 0px);">
<ul class="py-1 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdownDefault">
<li>
Dashboard
</li>
<li>
Settings
</li>
<li>
Earnings
</li>
<li>
Sign out
</li>
</ul>
</div>
<script src="https://unpkg.com/flowbite#1.5.1/dist/flowbite.js"></script>
</body>
Here an example without library, only react and tailwind.
const Sidebar = () => {
const [isOpen, setOpen] = useState(false);
const handleDropDown = () => {
setOpen(!isOpen);
};
return (
<div className="dropdown">
<button
className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2.5 text-center inline-flex items-center"
onClick={handleDropDown}
>
Steps
<svg
className="ml-2 w-4 h-4"
aria-hidden="true"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M19 9l-7 7-7-7"
></path>
</svg>
</button>
<div
id="dropdown"
className={`z-10 w-44 bg-white rounded divide-y divide-gray-100 shadow ${
isOpen ? "block" : "hidden"
}`}
>
<ul className=" z-10 w-44 bg-white rounded divide-y divide-gray-100 shadow ">
<li
>
<a href="#" className="block py-2 px-4 hover:bg-gray-100">
blablabla
</a>
</li>
</ul>
</div>
</div>
);
};
I am creating a simple login page using Django & Tailwind.css.
My form was styling fine until I inherited a <nav> from base.html. When I did so, gray borders started appearing around my input boxes and the input boxes got slightly bigger.
The original layout:
The new layout (with base.html being inherited):
I'm not sure why this is occurring, because all of the code remains the same, I am just {% extends "base.html" %} at the top of my login.html
Here is my base.html code (contains the navar & responsive navbar):
<!DOCTYPE html>
<html class="screen-top">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{% block title %}{% endblock %}</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght#400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://shuffle.dev/vendor/icons/css/fontello.css?v=h7b" id="bs-base-css">
<style type="text/css" href="https://shuffle.dev/vendor/tailwind-flex/css/tailwind.min.css?v=bd4"></style>
<style type="text/css" href="https://shuffle.dev/vendor/tailwind-flex/css/tailwind.min.css?v=bd4"></style>
<style type="text/css" href="css2?family=Poppins:wght#400;500;600;700&display=swap"></style>
<link rel="stylesheet" href="https://shuffle.dev/static/build/css/shuffle-preview.3a553ecf.css">
<link rel="stylesheet" href="https://unpkg.com/flowbite#latest/dist/flowbite.min.css" />
<script src="https://shuffle.dev/vendor/tailwind-flex/js/main.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
{% block css %}
{% endblock %}
</head>
<body id="page" class="antialiased font-body bg-body text-body bg-[rgb(248,250,251)]">
<!-- NAVBAR -->
<div class="" id="content">
<section class="relative overflow-hidden">
<nav class="flex justify-between p-6 px-4" data-config-id="toggle-mobile" data-config-target=".navbar-menu"
data-config-class="hidden" style="background-color: #2a3342;">
<div class="flex justify-between items-center w-full">
<div class="w-1/2 xl:w-1/3">
<a class="block max-w-max" href="{% url 'home' %}">
<img class="h-8" src="https://i.ibb.co/LRCrLTF/Screenshot-2022-04-03-140946-removebg-preview.png"
alt="LOGO" data-config-id="auto-img-1-2" style="transform: scale(2); padding-left: 30px"> </a>
</div>
<div class="w-1/2 xl:w-1/3">
<ul class="text-slate-400hidden xl:flex xl:justify-center">
<li class="mr-12"><a class="text-slate-400 font-medium hover:text-white transition ease-in-out delay-150"
href="#" data-config-id="auto-txt-1-2" style=" font-size: 18px">About</a></li>
<li class="mr-12"><a
class=" text-slate-400 font-medium hover:text-white transition ease-in-out delay-150"
href="{% url 'classes' %}" data-config-id="auto-txt-2-2" style=" font-size: 18px">Classes</a></li>
<li class="mr-12"><a class=" hover:text-white font-medium text-slate-400 transition ease-in-out delay-150"
href="{% url 'resources' %}" data-config-id="auto-txt-3-2" style=" font-size: 18px">Resources</a>
</li>
<li><a class=" hover:text-white font-medium text-slate-400 transition ease-in-out delay-150" href="#"
data-config-id="auto-txt-4-2" style=" font-size: 18px" id="responsivehide">Upcoming</a></li>
</ul>
</div>
<div class="w-1/2 xl:w-1/3">
<div class="hidden xl:flex items-center justify-end"><a
class="inline-block py-2 px-4 mr-2 leading-5 text-slate-400 hover:text-white bg-transparent font-medium rounded-md transition ease-in-out delay-150"
href="{% url 'login' %}" data-config-id="auto-txt-5-2" style="font-size: 18px">Log In</a><a
class="inline-block py-2 px-4 text-sm leading-5 text-green-50 border-2 border-solid border-green-500 hover:bg-green-500 transition ease-in-out delay-200 font-medium focus:ring-2 focus:ring-green-500 focus:ring-opacity-50 rounded-md"
href="#" data-config-id="auto-txt-6-2" style="font-size: 15px">Sign Up</a></div>
</div>
</div>
<button class="navbar-burger self-center xl:hidden">
<svg width="35" height="35" viewbox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"
data-config-id="auto-svg-1-2">
<rect class="text-slate-400" width="32" height="32" rx="6" fill="currentColor"></rect>
<path class="text-coolGray-400"
d="M7 12H25C25.2652 12 25.5196 11.8946 25.7071 11.7071C25.8946 11.5196 26 11.2652 26 11C26 10.7348 25.8946 10.4804 25.7071 10.2929C25.5196 10.1054 25.2652 10 25 10H7C6.73478 10 6.48043 10.1054 6.29289 10.2929C6.10536 10.4804 6 10.7348 6 11C6 11.2652 6.10536 11.5196 6.29289 11.7071C6.48043 11.8946 6.73478 12 7 12ZM25 15H7C6.73478 15 6.48043 15.1054 6.29289 15.2929C6.10536 15.4804 6 15.7348 6 16C6 16.2652 6.10536 16.5196 6.29289 16.7071C6.48043 16.8946 6.73478 17 7 17H25C25.2652 17 25.5196 16.8946 25.7071 16.7071C25.8946 16.5196 26 16.2652 26 16C26 15.7348 25.8946 15.4804 25.7071 15.2929C25.5196 15.1054 25.2652 15 25 15ZM25 20H7C6.73478 20 6.48043 20.1054 6.29289 20.2929C6.10536 20.4804 6 20.7348 6 21C6 21.2652 6.10536 21.5196 6.29289 21.7071C6.48043 21.8946 6.73478 22 7 22H25C25.2652 22 25.5196 21.8946 25.7071 21.7071C25.8946 21.5196 26 21.2652 26 21C26 20.7348 25.8946 20.4804 25.7071 20.2929C25.5196 20.1054 25.2652 20 25 20Z"
fill="currentColor"></path>
</svg></button>
</nav>
<!--NAVBAR ENDING-->
<!--Navbar script & styles-->
<script>
for (var i = 0; i < links.length; i += 1) {
links[i].addEventListener('click', function (e) {
e.preventDefault();
});
}
var forms = document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i += 1) {
forms[i].addEventListener('submit', function (e) {
e.preventDefault();
}, true);
}
</script>
<style>
#media screen and (min-width: 0px) and (max-width: 1273px) {
.mr-12 {
display: none;
}
#responsivehide {
display: none;
}
}
</style>
<div class="navbar-menu hidden fixed top-0 z-50 left-0 w-full h-full bg-coolGray-900 bg-opacity-50">
<div class="fixed top-0 left-0 bottom-0 w-full w-4/6 max-w-xs bg-coolGray-900" data-config-id="toggle-mobile-2"
data-config-target=".navbar-menu" data-config-class="hidden">
</div>
</div>
<!--Hidden navbar-->
<div class="hidden navbar-menu fixed top-0 left-0 bottom-0 w-5/6 max-w-sm z-50">
<div class="navbar-backdrop fixed inset-0 bg-gray-800 opacity-25"></div>
<nav class="relative flex flex-col py-6 px-6 h-full w-full bg-white border-r overflow-y-auto"
style="background-color: #2A3342;">
<div class="flex items-center mb-8 ">
<img class="h-8" src="https://i.ibb.co/LRCrLTF/Screenshot-2022-04-03-140946-removebg-preview.png" alt="LOGO"
data-config-id="auto-img-1-2" style="transform: scale(2); padding-left: 30px"> </a>
<a class="mr-auto text-3xl font-bold leading-none" href="#">
<img class="h-10" src="atis-assets/logo/atis/atis-mono-black.svg" alt="" width="auto">
</a>
<button class="navbar-close">
<svg class="h-6 w-6 text-gray-400 cursor-pointer hover:text-gray-500" xmlns="http://www.w3.org/2000/svg"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<div>
<ul>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">About</a></li>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">Classes</a></li>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">Recources</a></li>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">Upcoming</a></li>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">Contact Us!</a></li>
</ul>
</div>
<div class="mt-auto">
<div class="pt-6"><a
class="block px-4 py-3 mb-3 leading-loose text-xs text-center font-semibold leading-none bg-slate-400 hover:bg-gray-100 rounded-l-xl rounded-t-xl transition ease-in-out delay-150 text-white bg-slate-700 hover:bg-slate-400 focus:ring-4 focus:outline-none focus:ring-slate-300 font-medium rounded-lg text-base px-6 py-3.5 text-center dark:bg-slate-600 dark:hover:bg-slate-700 dark:focus:ring-slate-800"
href="{% url 'login' %}">Sign In</a><a
class="block px-4 py-3 mb-3 leading-loose text-xs text-center font-semibold leading-none bg-green-400 hover:bg-green-100 rounded-l-xl rounded-t-xl transition ease-in-out delay-150 text-white bg-green-700 hover:bg-green-400 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-base px-6 py-3.5 text-center dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800"
href="#">Sign Up</a></div>
<p class="my-4 text-xs text-center text-gray-400">
<span>© 2022 All rights reserved.</span>
</p>
</div>
</nav>
</div>
{% block content %}
{% endblock %}
{% block js %}
{% endblock %}
</section>
</div>
</body>
</html>
And here is my login.html (contains the login form):
{% extends "base.html" %}
{% block title %}Saroga | Login {% endblock %}
{% block content %}
<section class="bg-slate-900">
<div class="flex flex-wrap h-screen">
<div class="pt-7 lg:pt-16 pb-6 w-full lg:w-1/2" >
<div class="max-w-md mx-auto">
<div>
<div class="mb-7 px-3">
<span class="text-gray-400 text-xl ">Join a yoga session today!</span>
<h3 class="text-3xl font-bold text-white" style="padding-top: 3%">Login to your account</h3>
</div>
<form action="" method="POST">
{% csrf_token %}
<div class="flex flex-wrap">
</div>
<label for="username" class = "ml-2 text-green-500">Username:</label>
<div class="mb-3 mt-1 flex p-4 mx-2 bg-gray-800 rounded">
<input class="w-full text-medium text-gray-50 bg-gray-800 outline-none " id = "username" name="username" type="text" placeholder="ex: username"
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-user-circle" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="#d4d4dc" fill="none" stroke-linecap="round" stroke-linejoin="round" style = "transform: scale(1.1) ;">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<circle cx="12" cy="12" r="9"></circle>
<circle cx="12" cy="10" r="3"></circle>
<path d="M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855"></path>
</svg>
</button>
</div>
<label for="username" class = "ml-2 text-green-500">Password:</label>
<div class="mb-6 flex p-4 mx-2 bg-gray-800 rounded mt-1">
<input class="w-full text-medium text-gray-50 bg-gray-800 outline-none" type="password" name="password" placeholder="**********">
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="#d4d4dc" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
</svg>
</button>
</div>
<div class="px-3 text-center">
<button class="mb-2 w-full py-4 bg-green-500 hover:bg-green-700 rounded text-sm font-extrabold text-base text-gray-50 transition duration-200 " style="margin-bottom: 7%">Log In!</button>
<span class="text-gray-400 text-md ">
<span>Don't have an account?</span>
<a class="text-green-600 hover:underline" href="#">Create One Today!</a>
</span>
<p class="mt-16 text-md text-gray-400"><a class="text-green-600" href="#">Please read our</a> <a class="underline hover:text-gray-500" href="{% url 'privacyPolicy'%}">Privacy Policy</a> and <a class="underline hover:text-gray-500" href="{% url 'termsOfUse'%}">Terms of Use</a></p>
</div>
</form>
</div>
</div>
</div>
<div class="hidden lg:block relative w-full lg:w-1/2 bg-green-600">
<div class="absolute bottom-0 inset-x-0 mx-auto mb-12 max-w-xl text-center" style="z-index: 10;">
<img class="lg:max-w-xl mx-auto" src="https://i.ibb.co/7pH88PM/Woman-in-yoga-pose-removebg-preview-removebg-preview-1-1.png" style="position: relative; bottom: 150px">
<h2 class="mb-2 text-2xl text-white font-bold" style="position: relative; bottom: 100px">"Yoga shapes the soul, the mind, and the body"</h2>
<div class="max-w-lg mx-auto">
<p class="mb-6 text-gray-50 leading-loose" style="position: relative; bottom: 70px">Yoga is a truly benefical activity, packed with fun, simplicity, and flexibility. Join a yoga session today or visit the <a href = "{% url 'resources'%}" class="underline decoration-slate-500 font-bold decoration-4" > resources</a> page to learn more! </p>
</div> <script> for (var i = 0; i < quoteList.length; i ++) {return yoga_app.quote(i); } </script>
</div>
</div>
<div class="lg:hidden bg-green-600 w-full">
<div class="py-10 px-3 text-center" style="z-index: 10;">
<h2 class="mb-2 text-2xl text-white font-bold">"Yoga shapes the soul, the mind, and the body"</h2>
<p class="mb-6 text-gray-50 leading-loose">Yoga is a truly benefical activity, packed with fun, simplicity, and flexibility. Join a yoga session today or visit the <a href = "{% url 'resources'%}" class="underline decoration-slate-500 font-bold decoration-4" > resources</a> page to learn more!</p>
</div>
</div>
</div>
</section>
{% endblock %}
{% block js %}
<script>
for (var i = 0; i < links.length; i += 1) {
links[i].addEventListener('click', function (e) {
e.preventDefault();
});
}
var forms = document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i += 1) {
forms[i].addEventListener('submit', function (e) {
e.preventDefault();
}, true);
}
</script>
{% endblock %}
{% block css %}
<style>
#media screen and (min-width: 0px) and (max-width: 1272px) {
.mr-12 { display: none; }
#responsivehide { display: none; }
}
</style>
{% endblock %}
Can someone please help me find out why the input boxes are styling weirdly, and how I can solve it?
I am creating a simple login page using Django & Tailwind.css.
My form was styling fine until I inherited a <nav> from base.html. When I did so, gray borders started appearing around my input boxes and the input boxes got slightly bigger.
The original layout:
https://ibb.co/vXxgrH0
The new layout (with base.html being inherited):
https://ibb.co/QCsvKmz
I'm not sure why this is occurring, because all of the code remains the same, I am just {% extends "base.html" %} at the top of my login.html
Here is my base.html code (contains the navar & responsive navbar):
<!DOCTYPE html>
<html class="screen-top">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{% block title %}{% endblock %}</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght#400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://shuffle.dev/vendor/icons/css/fontello.css?v=h7b" id="bs-base-css">
<style type="text/css" href="https://shuffle.dev/vendor/tailwind-flex/css/tailwind.min.css?v=bd4"></style>
<style type="text/css" href="https://shuffle.dev/vendor/tailwind-flex/css/tailwind.min.css?v=bd4"></style>
<style type="text/css" href="css2?family=Poppins:wght#400;500;600;700&display=swap"></style>
<link rel="stylesheet" href="https://shuffle.dev/static/build/css/shuffle-preview.3a553ecf.css">
<link rel="stylesheet" href="https://unpkg.com/flowbite#latest/dist/flowbite.min.css" />
<script src="https://shuffle.dev/vendor/tailwind-flex/js/main.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
{% block css %}
{% endblock %}
</head>
<body id="page" class="antialiased font-body bg-body text-body bg-[rgb(248,250,251)]">
<!-- NAVBAR -->
<div class="" id="content">
<section class="relative overflow-hidden">
<nav class="flex justify-between p-6 px-4" data-config-id="toggle-mobile" data-config-target=".navbar-menu"
data-config-class="hidden" style="background-color: #2a3342;">
<div class="flex justify-between items-center w-full">
<div class="w-1/2 xl:w-1/3">
<a class="block max-w-max" href="{% url 'home' %}">
<img class="h-8" src="https://i.ibb.co/LRCrLTF/Screenshot-2022-04-03-140946-removebg-preview.png"
alt="LOGO" data-config-id="auto-img-1-2" style="transform: scale(2); padding-left: 30px"> </a>
</div>
<div class="w-1/2 xl:w-1/3">
<ul class="text-slate-400hidden xl:flex xl:justify-center">
<li class="mr-12"><a class="text-slate-400 font-medium hover:text-white transition ease-in-out delay-150"
href="#" data-config-id="auto-txt-1-2" style=" font-size: 18px">About</a></li>
<li class="mr-12"><a
class=" text-slate-400 font-medium hover:text-white transition ease-in-out delay-150"
href="{% url 'classes' %}" data-config-id="auto-txt-2-2" style=" font-size: 18px">Classes</a></li>
<li class="mr-12"><a class=" hover:text-white font-medium text-slate-400 transition ease-in-out delay-150"
href="{% url 'resources' %}" data-config-id="auto-txt-3-2" style=" font-size: 18px">Resources</a>
</li>
<li><a class=" hover:text-white font-medium text-slate-400 transition ease-in-out delay-150" href="#"
data-config-id="auto-txt-4-2" style=" font-size: 18px" id="responsivehide">Upcoming</a></li>
</ul>
</div>
<div class="w-1/2 xl:w-1/3">
<div class="hidden xl:flex items-center justify-end"><a
class="inline-block py-2 px-4 mr-2 leading-5 text-slate-400 hover:text-white bg-transparent font-medium rounded-md transition ease-in-out delay-150"
href="{% url 'login' %}" data-config-id="auto-txt-5-2" style="font-size: 18px">Log In</a><a
class="inline-block py-2 px-4 text-sm leading-5 text-green-50 border-2 border-solid border-green-500 hover:bg-green-500 transition ease-in-out delay-200 font-medium focus:ring-2 focus:ring-green-500 focus:ring-opacity-50 rounded-md"
href="#" data-config-id="auto-txt-6-2" style="font-size: 15px">Sign Up</a></div>
</div>
</div>
<button class="navbar-burger self-center xl:hidden">
<svg width="35" height="35" viewbox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"
data-config-id="auto-svg-1-2">
<rect class="text-slate-400" width="32" height="32" rx="6" fill="currentColor"></rect>
<path class="text-coolGray-400"
d="M7 12H25C25.2652 12 25.5196 11.8946 25.7071 11.7071C25.8946 11.5196 26 11.2652 26 11C26 10.7348 25.8946 10.4804 25.7071 10.2929C25.5196 10.1054 25.2652 10 25 10H7C6.73478 10 6.48043 10.1054 6.29289 10.2929C6.10536 10.4804 6 10.7348 6 11C6 11.2652 6.10536 11.5196 6.29289 11.7071C6.48043 11.8946 6.73478 12 7 12ZM25 15H7C6.73478 15 6.48043 15.1054 6.29289 15.2929C6.10536 15.4804 6 15.7348 6 16C6 16.2652 6.10536 16.5196 6.29289 16.7071C6.48043 16.8946 6.73478 17 7 17H25C25.2652 17 25.5196 16.8946 25.7071 16.7071C25.8946 16.5196 26 16.2652 26 16C26 15.7348 25.8946 15.4804 25.7071 15.2929C25.5196 15.1054 25.2652 15 25 15ZM25 20H7C6.73478 20 6.48043 20.1054 6.29289 20.2929C6.10536 20.4804 6 20.7348 6 21C6 21.2652 6.10536 21.5196 6.29289 21.7071C6.48043 21.8946 6.73478 22 7 22H25C25.2652 22 25.5196 21.8946 25.7071 21.7071C25.8946 21.5196 26 21.2652 26 21C26 20.7348 25.8946 20.4804 25.7071 20.2929C25.5196 20.1054 25.2652 20 25 20Z"
fill="currentColor"></path>
</svg></button>
</nav>
<!--NAVBAR ENDING-->
<!--Navbar script & styles-->
<script>
for (var i = 0; i < links.length; i += 1) {
links[i].addEventListener('click', function (e) {
e.preventDefault();
});
}
var forms = document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i += 1) {
forms[i].addEventListener('submit', function (e) {
e.preventDefault();
}, true);
}
</script>
<style>
#media screen and (min-width: 0px) and (max-width: 1273px) {
.mr-12 {
display: none;
}
#responsivehide {
display: none;
}
}
</style>
<div class="navbar-menu hidden fixed top-0 z-50 left-0 w-full h-full bg-coolGray-900 bg-opacity-50">
<div class="fixed top-0 left-0 bottom-0 w-full w-4/6 max-w-xs bg-coolGray-900" data-config-id="toggle-mobile-2"
data-config-target=".navbar-menu" data-config-class="hidden">
</div>
</div>
<!--Hidden navbar-->
<div class="hidden navbar-menu fixed top-0 left-0 bottom-0 w-5/6 max-w-sm z-50">
<div class="navbar-backdrop fixed inset-0 bg-gray-800 opacity-25"></div>
<nav class="relative flex flex-col py-6 px-6 h-full w-full bg-white border-r overflow-y-auto"
style="background-color: #2A3342;">
<div class="flex items-center mb-8 ">
<img class="h-8" src="https://i.ibb.co/LRCrLTF/Screenshot-2022-04-03-140946-removebg-preview.png" alt="LOGO"
data-config-id="auto-img-1-2" style="transform: scale(2); padding-left: 30px"> </a>
<a class="mr-auto text-3xl font-bold leading-none" href="#">
<img class="h-10" src="atis-assets/logo/atis/atis-mono-black.svg" alt="" width="auto">
</a>
<button class="navbar-close">
<svg class="h-6 w-6 text-gray-400 cursor-pointer hover:text-gray-500" xmlns="http://www.w3.org/2000/svg"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<div>
<ul>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">About</a></li>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">Classes</a></li>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">Recources</a></li>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">Upcoming</a></li>
<li class="mb-1"><a
class="block p-4 text-sm font-semibold text-gray-400 hover:bg-green-50 hover:text-green-600 rounded"
href="#">Contact Us!</a></li>
</ul>
</div>
<div class="mt-auto">
<div class="pt-6"><a
class="block px-4 py-3 mb-3 leading-loose text-xs text-center font-semibold leading-none bg-slate-400 hover:bg-gray-100 rounded-l-xl rounded-t-xl transition ease-in-out delay-150 text-white bg-slate-700 hover:bg-slate-400 focus:ring-4 focus:outline-none focus:ring-slate-300 font-medium rounded-lg text-base px-6 py-3.5 text-center dark:bg-slate-600 dark:hover:bg-slate-700 dark:focus:ring-slate-800"
href="{% url 'login' %}">Sign In</a><a
class="block px-4 py-3 mb-3 leading-loose text-xs text-center font-semibold leading-none bg-green-400 hover:bg-green-100 rounded-l-xl rounded-t-xl transition ease-in-out delay-150 text-white bg-green-700 hover:bg-green-400 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-base px-6 py-3.5 text-center dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800"
href="#">Sign Up</a></div>
<p class="my-4 text-xs text-center text-gray-400">
<span>© 2022 All rights reserved.</span>
</p>
</div>
</nav>
</div>
{% block content %}
{% endblock %}
{% block js %}
{% endblock %}
</section>
</div>
</body>
</html>
And here is my login.html (contains the login form):
{% extends "base.html" %}
{% block title %}Saroga | Login {% endblock %}
{% block content %}
<section class="bg-slate-900">
<div class="flex flex-wrap h-screen">
<div class="pt-7 lg:pt-16 pb-6 w-full lg:w-1/2" >
<div class="max-w-md mx-auto">
<div>
<div class="mb-7 px-3">
<span class="text-gray-400 text-xl ">Join a yoga session today!</span>
<h3 class="text-3xl font-bold text-white" style="padding-top: 3%">Login to your account</h3>
</div>
<form action="" method="POST">
{% csrf_token %}
<div class="flex flex-wrap">
</div>
<label for="username" class = "ml-2 text-green-500">Username:</label>
<div class="mb-3 mt-1 flex p-4 mx-2 bg-gray-800 rounded">
<input class="w-full text-medium text-gray-50 bg-gray-800 outline-none " id = "username" name="username" type="text" placeholder="ex: username"
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-user-circle" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="#d4d4dc" fill="none" stroke-linecap="round" stroke-linejoin="round" style = "transform: scale(1.1) ;">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<circle cx="12" cy="12" r="9"></circle>
<circle cx="12" cy="10" r="3"></circle>
<path d="M6.168 18.849a4 4 0 0 1 3.832 -2.849h4a4 4 0 0 1 3.834 2.855"></path>
</svg>
</button>
</div>
<label for="username" class = "ml-2 text-green-500">Password:</label>
<div class="mb-6 flex p-4 mx-2 bg-gray-800 rounded mt-1">
<input class="w-full text-medium text-gray-50 bg-gray-800 outline-none" type="password" name="password" placeholder="**********">
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="#d4d4dc" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
</svg>
</button>
</div>
<div class="px-3 text-center">
<button class="mb-2 w-full py-4 bg-green-500 hover:bg-green-700 rounded text-sm font-extrabold text-base text-gray-50 transition duration-200 " style="margin-bottom: 7%">Log In!</button>
<span class="text-gray-400 text-md ">
<span>Don't have an account?</span>
<a class="text-green-600 hover:underline" href="#">Create One Today!</a>
</span>
<p class="mt-16 text-md text-gray-400"><a class="text-green-600" href="#">Please read our</a> <a class="underline hover:text-gray-500" href="{% url 'privacyPolicy'%}">Privacy Policy</a> and <a class="underline hover:text-gray-500" href="{% url 'termsOfUse'%}">Terms of Use</a></p>
</div>
</form>
</div>
</div>
</div>
<div class="hidden lg:block relative w-full lg:w-1/2 bg-green-600">
<div class="absolute bottom-0 inset-x-0 mx-auto mb-12 max-w-xl text-center" style="z-index: 10;">
<img class="lg:max-w-xl mx-auto" src="https://i.ibb.co/7pH88PM/Woman-in-yoga-pose-removebg-preview-removebg-preview-1-1.png" style="position: relative; bottom: 150px">
<h2 class="mb-2 text-2xl text-white font-bold" style="position: relative; bottom: 100px">"Yoga shapes the soul, the mind, and the body"</h2>
<div class="max-w-lg mx-auto">
<p class="mb-6 text-gray-50 leading-loose" style="position: relative; bottom: 70px">Yoga is a truly benefical activity, packed with fun, simplicity, and flexibility. Join a yoga session today or visit the <a href = "{% url 'resources'%}" class="underline decoration-slate-500 font-bold decoration-4" > resources</a> page to learn more! </p>
</div> <script> for (var i = 0; i < quoteList.length; i ++) {return yoga_app.quote(i); } </script>
</div>
</div>
<div class="lg:hidden bg-green-600 w-full">
<div class="py-10 px-3 text-center" style="z-index: 10;">
<h2 class="mb-2 text-2xl text-white font-bold">"Yoga shapes the soul, the mind, and the body"</h2>
<p class="mb-6 text-gray-50 leading-loose">Yoga is a truly benefical activity, packed with fun, simplicity, and flexibility. Join a yoga session today or visit the <a href = "{% url 'resources'%}" class="underline decoration-slate-500 font-bold decoration-4" > resources</a> page to learn more!</p>
</div>
</div>
</div>
</section>
{% endblock %}
{% block js %}
<script>
for (var i = 0; i < links.length; i += 1) {
links[i].addEventListener('click', function (e) {
e.preventDefault();
});
}
var forms = document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i += 1) {
forms[i].addEventListener('submit', function (e) {
e.preventDefault();
}, true);
}
</script>
{% endblock %}
{% block css %}
<style>
#media screen and (min-width: 0px) and (max-width: 1272px) {
.mr-12 { display: none; }
#responsivehide { display: none; }
}
</style>
{% endblock %}
Can someone please help me find out why the input boxes are styling weirdly, and how I can solve it?
How to open specific collapsible panel inside modal by clicking in link I'm trying to make a layered filter modal, but i can not create links to appropriate panels in this modal.
We use alpine.js and magento 2 for this. Here is our code.
It would be great if you could help us
<section x-cloak x-data="{open: false}"
:class="open ? 'overflow-hidden ' : 'overflow-visible '">
<div class="border-b border-container-lighter flex pb-6">
<?php foreach ($block->getFilters() as $filter): ?>
<?php if ($filter->getItemsCount()): ?>
<button
#click="open = true"
class="flex-initial items-center text-sm py-2.5 px-4 rounded-full bg-gray-100 mr-2">
<?= $escaper->escapeHtml(__($filter->getName())) ?>
</button>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?= $block->getChildHtml('state') ?>
<div role="dialog"
aria-labelledby="modal1_label"
aria-modal="true"
tabindex="0"
x-show="open"
#click.away="open = false"
class="fixed inset-x-0 bottom-0 md:inset-x-auto md:inset-y-0 md:right-0 z-30 flex max-w-full">
<div class="backdrop"
x-show="open"
x-transition:enter="ease-in-out duration-500"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="ease-in-out duration-500"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
#click="open = false"
aria-label="Close panel"></div>
<div data-modal-document
#click.stop=""
x-show="open"
x-transition:enter="transform transition ease-in-out duration-500 sm:duration-700"
x-transition:enter-start="translate-y-full sm:-translate-y-0 sm:translate-x-full"
x-transition:enter-end=" sm:translate-x-0"
x-transition:leave="transform transition ease-in-out duration-500 sm:duration-700"
x-transition:leave-start="sm:translate-x-0"
x-transition:leave-end="translate-y-full sm:-translate-y-0 sm:translate-x-full"
class="bg-white relative w-screen max-w-md shadow-2xl">
<div
x-show="open"
x-transition:enter="ease-in-out duration-500"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="ease-in-out duration-500"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0" class="absolute top-0 right-0 flex p-2 mt-2">
<button #click="open = false;" aria-label="Close panel"
class="p-2 text-gray-300 transition duration-150 ease-in-out hover:text-black">
<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="M6 18L18 6M6 6l12 12">
</path>
</svg>
</button>
</div>
<div class="flex flex-col h-full py-6 space-y-6 bg-white shadow-xl">
<header class="px-4 sm:px-6">
<h2 id="cart-drawer-title" class="text-lg font-medium leading-7 text-gray-900">
<?= $escaper->escapeHtml(__('Filtern und sortieren')) ?>
</h2>
</header>
<div class="relative grid gap-6 px-6 py-6 overflow-y-auto bg-white
sm:gap-8 sm:px-6 border-container">
<div class="w-full">
<div class="container block p-4 md:border-0 md:bg-transparent md:py-0 md:px-0 my-6"
x-data="initLayeredNavigation()"
x-init="checkIsMobileResolution()"
#resize.window.debounce="checkIsMobileResolution()"
#visibilitychange.window.debounce="checkIsMobileResolution()"
>
<div class="block-content filter-content pt-3" >
<?= $block->getChildHtml('state') ?>
<?php foreach ($block->getFilters() as $filter): ?>
<?php if ($filter->getItemsCount()): ?>
<div class="filter-option my-6" id="filter-<?= $escaper->escapeHtml(__($filter->getName())) ?>" x-data="{ open: false }">
<div
class="filter-options-title flex justify-between items-center cursor-pointer hover:text-secondary-darker border-container"
:class="{ 'border-b pb-4': open }"
#click="open = !open"
#open-dropdown.window=" open = true"
#click.away="open = false">
<span class="title text-md md:text-base font-light">
<?= $escaper->escapeHtml(__($filter->getName())) ?>
</span>
<span class="">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg"
class="transition-transform transform duration-300 ease-in-out"
:class="open ? 'rotate-180' : ''">
<path d="M19 9L12 16L5 9" stroke="#4A5568" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round"/>
</svg>
</span>
</div>
<div class="filter-options-content pt-3 hidden"
:class="{ 'hidden': !open , 'block': 'open' }"
>
<?= /* #noEscape */
$block->getChildBlock('renderer')->render($filter) ?>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
How to open specific collapsible panel inside modal by clicking in link I'm trying to make a layered filter modal, but i can not create links to appropriate panels in this modal.
I have a navbar and sidebar component in my nextjs app.
In my index component I'm using useState to show and hide sidebar on mobile device.
It works perfectly fine but I want to add animation when user clicks on hamburger menu, the sidebar should be animated left to right and when clicked on close icon it should go back to right to left. FYI I am using tailwind css.
Here's the code:
indexjs file:
export default function Home() {
const [sidebar, setSidebar] = useState(false);
return(
<>
<Navbar sidebar={sidebar} setSidebar={setSidebar} />
{sidebar ? (
<div className={sidebar ? "transform-x-0" : "transform-x-full"}>
<Sidebar sidebar={sidebar} setSidebar={setSidebar} />
</div>
) : null}
</>
)
Navbar.js:
const Navbar = ({ sidebar, setSidebar }) => {
return (
<div>
<header className="px-4 max-w-desktop mx-auto text-blacklight">
<nav
className="
flex
lg:flex-row
items-center
flex-auto
justify-between
lg:mx-auto
md:py-6
py-4
relative
navigation
"
id="navigation"
>
<div className="flex flex-row items-center">
<img src="./assets/logo.svg" alt="fab systems" />
<h2 className="text-lg font-extrabold flex-none ml-1 leading-none">
FAB <br />
SYSTEMS
</h2>
</div>
<ul
className="
lg:flex lg:flex-row
flex-col
max-w-full
lg:w-2/3
mt-4
lg:mt-0
hidden
lg:items-center
justify-between
flex-none
"
>
<li className="menu-links">
Features
</li>
<li className="menu-links">
Pricing
</li>
<li className="menu-links">
Customer Results
</li>
<li className="menu-links">
About
</li>
<li className="menu-links">
Blog
</li>
<li className="menu-links">
Support
</li>
<div className="flex flex-col">
<li
className="
menu-links
bg-dark-blue
py-2
rounded-full
text-white
font-semibold
px-4
"
>
Free Demo
</li>
<p className="absolute right-0 w-screen text-right bottom-0 text-sm">
or call sales
<a href="https://twitter.com/" className="text-blue">
+91 982-488-5838
</a>
</p>
</div>
</ul>
<div className="lg:hidden">
<svg
className="w-8 h-8 lg:hidden"
id="hamburger"
onClick={() => setSidebar(true)}
fill="none"
stroke="#354650"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
></path>
</svg>
</div>
</nav>
</header>
</div>
);
};
export default Navbar;
Sidebar.js:
import React from "react";
const Sidebar = ({ sidebar, setSidebar }) => {
const hideSidebar = () => {
setSidebar(!sidebar);
};
return (
<div
className="
overflow-x-hidden
min-h-screen
absolute
z-50
bg-dark-green
lg:px-12
px-4
md:py-6
py-4
transform
left-0
w-screen
transition
duration-300
top-0
"
id="mobile-nav"
>
<div className="flex flex-row justify-between items-center">
<div>
<img src="./assets/logo.svg" alt="fab systems" />
</div>
<svg
className="w-8 h-8 lg:hidden mr-2"
id="close"
onClick={hideSidebar}
fill="none"
stroke="#FFFFFF"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
></path>
</svg>
</div>
<ul className="text-xl text-white my-4">
<li className="menu-links py-4 border-gray-600 border-b-2">
Features
</li>
<li className="menu-links py-4 border-gray-600 border-b-2">
Pricing
</li>
<li className="menu-links py-4 border-gray-600 border-b-2">
Customer Results
</li>
<li className="menu-links py-4 border-gray-600 border-b-2">
About
</li>
<li className="menu-links py-4 border-gray-600 border-b-2">
Blog
</li>
<li className="menu-links py-4 border-gray-600 border-b-2">
Support
</li>
<li className="menu-links py-4">
Free Demo
</li>
</ul>
<div className="relative py-1 w-screen flex flex-row pr-4">
<input
type="email"
className="
p-2
px-3
border-gray-400
rounded-tl rounded-bl
border
text-sm
relative
max-w-full
w-full
"
placeholder="Enter your phone"
/>
<button
className="
py-2
text-white
rounded-tr-full rounded-br-full
bg-dark-blue
text-sm
px-4
mr-4
sm:w-1/4
w-1/2
border border-blue-600
-ml-2
"
>
Try Free Demo
</button>
</div>
</div>
);
};
export default Sidebar;
Can you try this?
<div className={`sidebar ${sidebar ? "transform-x-0" : "transform-x-full"}`}>
And give .sidebar transition ?