Dropdown pass behind swiperjs, z-index issue or tailwindcss issue? - html

I'm trying to use SwiperJS but I have a problem with the z-index I think.
I have my menu going below the slider and I don't understand how this is happening.
I tried to put a z-index: 1000 on the menu and a z-index: 1 on the slider.
I tried to put a z-index: -1 on the slider and it works, but I lose the use of the navigation buttons...
Am I blind? I think so.
<header class="menu">
<div class="menu__logo">
<a href="/">
kappa
</a>
</div>
<div class="menu__nav">
<ul>
<li>
<a href="#">
kappa
</a>
</li>
<li>
<a href="#">
kappa
</a>
</li>
<li class="menu__nav__dropdown" x-data="{open: false}" x-on:mouseover="open = true" x-on:mouseover.away="open = false">
<span>
kappa
</span>
<x-icons.array-down />
<div class="menu__nav__dropdown__block" x-show="open" x-transition:enter="transition ease-out duration-200" x-transition:enter-start="opacity-0 translate-y-1" x-transition:enter-end="opacity-100 translate-y-0" x-transition:leave="transition ease-in duration-150" x-transition:leave-start="opacity-100 translate-y-0" x-transition:leave-end="opacity-0 translate-y-1" #click.away="open = false" style="display: none;">
<div class="menu__nav__dropdown__block__bg">
<div class="menu__nav__dropdown__link__wrapper">
<a href="#" class="menu__nav__dropdown__link">
<p>
kappa
</p>
</a>
<a href="#" class="menu__nav__dropdown__link">
<p>
kappa
</p>
</a>
<a href="#" class="menu__nav__dropdown__link">
<p>
kappa
</p>
</a>
<a href="#" class="menu__nav__dropdown__link">
<p>
kappa
</p>
</a>
<a href="#" class="menu__nav__dropdown__link">
<p>
kappa
</p>
</a>
</div>
</div>
</div>
</li>
<li>
<a href="#">
kappa
</a>
</li>
</ul>
</div>
<div class="menu__phone">
<div class="menu__phone-icon">
<x-icons.phone />
</div>
<div class="menu__phone-number">
kappa
</div>
</div>
</header>
.menu {
#apply flex w-full justify-between py-4 sticky base;
}
.menu__logo {
#apply w-52;
}
.menu__nav ul {
#apply list-none flex gap-x-10;
}
.menu__nav {
#apply my-auto;
}
.menu__phone {
#apply flex gap-x-3;
}
.menu__phone-icon {
#apply bg-sc-orange p-2 fill-white;
}
.menu__phone-number {
#apply my-auto font-bold;
}
.menu__nav__dropdown {
#apply cursor-pointer fill-primary flex gap-x-3
}
.menu__nav__dropdown svg {
#apply my-auto
}
.menu__nav__dropdown__block {
#apply absolute left-1/2 transform -translate-x-1/2 mt-8 px-2 w-screen max-w-xs sm:px-0 z-10;
}
.menu__nav__dropdown__block__bg {
#apply shadow-lg ring-1 ring-black ring-opacity-5 z-10;
}
.menu__nav__dropdown__link__wrapper {
#apply relative grid gap-6 bg-white px-5 py-6 sm:gap-8 sm:p-8;
}
.menu__nav__dropdown__link {
#apply -m-3 p-3 block hover:bg-gray-50;
}
<div class="swiper">
<!-- Additional required wrapper -->
<div class="swiper-wrapper">
<!-- Slides -->
<div class="swiper-slide">
<img src="https://wallpapers.com/images/featured/g9rdx9uk2425fip2.jpg" class="md:min-w-full object-cover h-160 hidden md:block" width="1440" height="624" alt="slider 1" />
</div>
<div class="swiper-slide">
<img src="https://wallpapers.com/images/featured/g9rdx9uk2425fip2.jpg" class="md:min-w-full object-cover h-160 hidden md:block" width="1440" height="624" alt="slider 1" />
</div>
<div class="swiper-slide">
<img src="https://wallpapers.com/images/featured/g9rdx9uk2425fip2.jpg" class="md:min-w-full object-cover h-160 hidden md:block" width="1440" height="624" alt="slider 1" />
</div>
</div>
<!-- If we need navigation buttons -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
I would just like the menu to go in front of the slider.

Since your codes are complex, I will explain this with a simple example. I think the problem is that you haven't given the relative class to the field you want to stand out. If you are using z-index, you should also add the relative class. In the example below, you can see that if you remove the relative class from the title, the title will go to the back.If this is not enough, you should add that it is important to the classes. SwiperJS might be squashing your classes somehow.
Demo

I found the solution, I simply added the tailwind classes to the header : z-20 relative

Related

Using TailwindCSS to put logo in top left and menu in top right

I have managed to write some Tailwind CSS to put a logo in the top left hand corner of the screen, but now I cant seem to get a menu to render in the top right, this is what I have. Nothing I try seems to work. It just renders right next to the logo image
<div className="isolate">
<div className="px-6 pt-6 lg:px-8">
<div>
<nav
className="flex h-9 items-center justify-between"
aria-label="Global"
>
<div
className="flex lg:min-w-0 lg:flex-1"
aria-label="Global"
>
<a href="/" className="-m-1.5 p-1.5">
<span className="sr-only">This Company Name</span>
<img
className="h-8"
src="/this-company-logo.png"
alt="This Company Name"
/>
</a>
<ul>
<li>Home</li>
<li>Contact</li>
</ul>
</div>
</nav>
</div>
</div>
</div>
<div className="isolate">
<div className="px-6 pt-6 lg:px-8">
<nav className="flex items-center justify-between" aria-label="Global">
<div className="flex-1">
<a href="/" className="-m-1.5 p-1.5">
<span className="sr-only">This Company Name</span>
<img
className="h-8"
src="/this-company-logo.png"
alt="This Company Name"
/>
</a>
</div>
<div className="flex items-center">
<ul className="flex space-x-4">
<li>
Home
</li>
<li>
Contact
</li>
</ul>
</div>
</nav>
</div>
</div>
You have to just remove this tag
...
<div
className="flex lg:min-w-0 lg:flex-1"
aria-label="Global"
>
...
</div>
...

Tailwind CSS hide div on hover not hiding

I have a collection of images that appear as cards. The cards have text below them. I am trying to hide the text and show the image only using tailwind v2 with no luck.
My code :
<div class="group max-w-sm bg-white m-4 rounded-lg border border-gray-200 shadow-md dark:bg-gray-800 dark:border-gray-700">
<a href="#">
<img class="rounded-t-lg w-full h-64 object-cover" src="images/care.webp" alt="" />
</a>
<div class="p-1 visible group-hover:invisible">
<p class="visible group-hover:invisible text-center mb-3 font-normal text-gray-700 dark:text-gray-400">CARE</p>
</a>
</div>
</div>
<!-- end of card -->
<!-- Card -->
<div class="group max-w-sm bg-white m-4 rounded-lg border border-gray-200 shadow-md dark:bg-gray-800 dark:border-gray-700">
<a href="#">
<img class="rounded-t-lg w-full h-64 object-cover" src="images/kindness.jpg" alt="" />
</a>
<div class="p-1 invisible group-hover:visible">
<p class="invisible group-hover:visible text-center mb-3 font-normal text-gray-700 dark:text-gray-400">KINDNESS</p>
</a>
</div>
</div>
Any recommendations/advise on what i am doing wrong will be appreciated.
I have referenced documentation and stackoverflow with no luck
in your documentation link at the end there is such a code
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
visibility: ['hover', 'focus'],
}
}
}
so you have to add these parameters to your tailwind.config.js to make it work
and use these classes visible hover:invisible

Element with line-clamp too wide

I am using the #tailwindcss/line-clamp plugin to clamp a text element (<span>) to one line (line-clamp-1). The text element is inside a flex box, and is followed by another text element that's supposed to "stick" to its right side.
My problem is that the width of the clamped text element is not computed properly. Even though the text is clamped correctly, the width of the element remains too wide and the following text does not "stick" closely like I want to.
Below is a screenshot. The "problem element" is the one that says "Human-Computer Interaction". It should look like the others, where the "post count" in parentheses "sticks" closely to the topic label.
Here is my code:
{{#foreach tags}}
<a class="flex flex-row gap-1" href="{{url}}">
<span class="text-neutral-200 line-clamp-1"> {{name}}</span>
<span class="text-neutral-500"> ({{count.posts}})</span>
</a>
{{/foreach}}
How does one reduce the width of the clamped text element to fit the clamped text inside?
P.S. I have tried replacing <span>s with <p> elements, and using other CSS approaches that don't involve the line-clamp plugin, and have not found a solution so far.
There is no need to use an extra package because you only one have line and for achieve you can use text-overflow property with white-space and overflow to get the same result.
You can use it as inline or create you own class with #layer.
<script src="https://cdn.tailwindcss.com"></script>
<style type="text/tailwindcss">
#layer utilities { .ellip { #apply overflow-hidden text-ellipsis whitespace-nowrap; } }
</style>
<div class="grid grid-cols-4 gap-6 bg-black">
<div class="flex flex-col">
<a class="flex flex-row gap-1" href="/#">
<span class="overflow-hidden text-ellipsis whitespace-nowrap text-neutral-200"> Music</span>
<span class="text-neutral-500"> (7)</span>
</a>
<a class="flex flex-row gap-1" href="/#">
<span class="overflow-hidden text-ellipsis whitespace-nowrap text-neutral-200"> Architecture</span>
<span class="text-neutral-500"> (2)</span>
</a>
<a class="flex flex-row gap-1" href="/#">
<span class="overflow-hidden text-ellipsis whitespace-nowrap text-neutral-200"> Graphic Design</span>
<span class="text-neutral-500"> (10)</span>
</a>
<a class="flex flex-row gap-1" href="/#">
<span class="overflow-hidden text-ellipsis whitespace-nowrap text-neutral-200"> Human-Computer Interaction </span>
<span class="text-neutral-500"> (5)</span>
</a>
</div>
<div class="flex flex-col">
<a class="flex flex-row gap-1" href="/#">
<span class="text-neutral-200 ellip"> Human-Computer Interaction</span>
<span class="text-neutral-500"> (7)</span>
</a>
<a class="flex flex-row gap-1" href="/#">
<span class="text-neutral-200"> Art</span>
<span class="text-neutral-500"> (4)</span>
</a>
<a class="flex flex-row gap-1" href="/#">
<span class="text-neutral-200 ellip"> Education</span>
<span class="text-neutral-500"> (5)</span>
</a>
<a class="flex flex-row gap-1" href="/#">
<span class="text-neutral-200 ellip"> Graphic Design</span>
<span class="text-neutral-500"> (10)</span>
</a>
</div>
</div>

Different items height inside of div when using flexbox(TailwindCSS)

I am using Flex in tailwind in one my main div container to align the items inside of it horizontal
but somehow the items are of different sizes in the row the image link is below any fixes for it?
i have tried using height utility class but it just messes up the entire page.
[1]: https://i.stack.imgur.com/Yjs51.jpg
HOME
ORDERS
MENU CARD
FAQs
ABOUT
Butter Chicken
If you haven't tried butter chicken, you don't know what you'r missing.
</div>
</div>
</a>
<a href="butterchicken.html">
<div class="max-w-sm rounded overflow-hidden shadow-lg justify-center">
<img class= "w-full" src="images/download (1).jpg" alt="malai-chicken">
<div class="px-6 py-8">
<div class="font-extrabold text-xl pb-3">Malai Chicken</div>
<div>
<p class=" font-serif text-base mb-3">Clean as white and appetizing.</p>
</div>
</div>
</div>
</a>
</a>
<a href="butterchicken.html">
<div class="max-w-sm rounded overflow-hidden shadow-lg justify-center">
<img class= "w-full" src="images/download (2).jpg" alt="Shahi Paneer">
<div class="px-6 py-8">
<div class="font-extrabold text-xl pb-3">Shahi Paneer</div>
<div>
<p class=" font-serif text-base mb-3">First Pick of Royales.</p>
</div>
</div>
</div>
</a>
</div>

Why Footer is floating in tailwind css

I am using the tailwind CSS footer in my NextJS project. I am displaying fetched data. The footer is floating only when there are less data. I created a footer file in my pages and imported it into my _app.js file. I tried the absolute and fixed position. But it is not working. How do I keep my footer to the bottom?
<div className="relative mt-16 bg-gray-900">
<div className="px-4 pt-12 mx-auto sm:max-w-xl md:max-w-full lg:max-w-screen-xl md:px-24 lg:px-8">
<div className="flex flex-col-reverse justify-between pt-5 pb-10 border-t lg:flex-row">
<p className="text-base text-white-100">
© Copyright 2020. All rights reserved.
</p>
<ul className="flex flex-col mb-3 space-y-2 lg:mb-0 sm:space-y-0 sm:space-x-5 sm:flex-row">
<li>
<Link href="/Privacy">
<a className="text-sm tracking-wide font-medium text-white-100 transition-colors duration-300 hover:text-indigo-400">
Privacy Policy
</a>
</Link>
</li>
<li>
<a href="https://twitter.com/" target="_blank" rel="noreferrer noopener" className="text-sm tracking-wide font-medium text-white-100 transition-colors duration-300 hover:text-indigo-400">
Contact
</a>
</li>
</ul>
</div>
</div>
</div>
You could set a minimum height based on 100vh minus the height of the footer to the main content container.
<main class="min-h-[calc(100vh-210px)]">Main Content</main>
<footer class="h-[210px] bg-gray-900">
<!-- Your footer content -->
</footer>
Try it on TailwindCSS playground.