Tailwind CSS & Alpine JS transition out issue - css

I've got a very simple button & modal combo working inside Tailwind & Alpine - https://jsfiddle.net/0pso5cxh/
My issue is that on the leave transition (cancel button or close icon), none of the fade animation is happening at all and it just snaps to 0 opacity. This is my first use of both Tailwind and Alpine so any pointers would be massively appreciated!
<div x-data="{ addDonationOpen: false }">
<button #click="addDonationOpen = !addDonationOpen" class="bg-teal-700 hover:bg-teal-500 hover:text-gray-900 focus:bg-teal-500 focus:outline-none focus:shadow-outline text-white focus:text-gray-900 px-4 py-2 rounded font-medium mr-6"><i class="fas fa-plus-square pr-1"></i> Add Donation</button>
<div x-show="addDonationOpen" :class="{'flex': addDonationOpen, 'fixed': addDonationOpen, 'hidden': !addDonationOpen}" x-transition:enter="transition ease-out duration-300" x-transition:enter-start="transform opacity-0" x-transition:enter-end="transform opacity-100" x-transition:leave="transition ease-in duration-1000" x-transition:leave-start="transform opacity-100" x-transition:leave-end="transform opacity-0" class="w-full h-100 inset-0 z-50 overflow-hidden justify-center items-center" style="background: rgba(0,0,0,.7);">
<div class="border border-teal-500 shadow-lg modal-container bg-white w-11/12 md:max-w-md mx-auto rounded shadow-lg z-50 overflow-y-auto">
<div class="modal-content py-4 text-left px-6">
<!--Title-->
<div class="flex justify-between items-center pb-3">
<p class="text-2xl font-bold">Header</p>
<div #click="addDonationOpen = !addDonationOpen" class="modal-close cursor-pointer z-50">
<svg class="fill-current text-black" xmlns="http://www.w3.org/2000/svg" width="18" height="18"
viewBox="0 0 18 18">
<path
d="M14.53 4.53l-1.06-1.06L9 7.94 4.53 3.47 3.47 4.53 7.94 9l-4.47 4.47 1.06 1.06L9 10.06l4.47 4.47 1.06-1.06L10.06 9z">
</path>
</svg>
</div>
</div>
<!--Body-->
<div class="my-5">
<p>Inliberali Persius Multi iustitia pronuntiaret expeteretur sanos didicisset laus angusti ferrentur arbitrium arbitramur huic desiderent.?</p>
</div>
<!--Footer-->
<div class="flex justify-end pt-2">
<button #click="addDonationOpen = !addDonationOpen" class="focus:outline-none modal-close px-4 bg-gray-400 p-3 rounded-lg text-black hover:bg-gray-300">Cancel</button>
<button class="focus:outline-none px-4 bg-teal-500 p-3 ml-3 rounded-lg text-white hover:bg-teal-400">Confirm</button>
</div>
</div>
</div>
</div>
</div>

It's not getting a chance to do the out animation because you're applying a hidden class manually using the x-class binding.
You can remove the whole x-class set of conditions you've got there on line 4 - the x-show directive will handle all that for you in a way that manages the transition.
Just make sure you add the fixed class to your class= attribute so that it still gets applied to your CSS.

For me, I just use this code below in the head of file
<style>
[x-cloak] { display: none }
</style>
and x-cloak in any elements
x-cloak

Related

Vue3 transition sudden jump

my problem is that, after transitioned element fades, parent element jumps(not smoothly). I searched before asking in here but couldn't find the solution, thanks for the answers.
Here is the video about my issue:
https://streamable.com/us39pu
Main View Code: After adding new task or removing, animation works just fine with 'transition-group' e.g. no sudden jumps
<ul class="p-4 grid gap-2 grid-cols-1 relative">
<TransitionGroup
appear
move-class="transform transition duration-500 ease-in-out"
enter-active-class="transform transition duration-500 ease-in-out"
enter-from-class="opacity-0 scale-x-0 translate-x-1/2"
enter-to-class="opacity-100 scale-x-100 translate-x-0"
leave-active-class="transform transition duration-1000 ease-in-out absolute w-full "
leave-from-class="opacity-100 scale-x-100 translate-x-0"
leave-to-class="opacity-0 scale-x-0 translate-x-1/2"
>
<li v-for="task in tasks" :key="task.id">
<Task
:task="task"
#remove-task="removeTask"
#edit-task="editTask"
/>
</li>
</TransitionGroup>
</ul>
Task Component: Here editing div and removing animations works fine with 'transition' but after it fades main component jumps e.g. not smoothly
<transition
enter-active-class="transition transform duration-500 ease-in-out"
enter-from-class="scale-y-0 opacity-0 translate-y-1/2"
enter-to-class="scale-y-full opacity-100 translate-y-0"
leave-active-class="transition transform duration-500 ease-in-out"
leave-from-class="scale-y-full opacity-100 translate-y-0"
leave-to-class="scale-y-0 opacity-0 translate-y-1/2"
>
<div class="flex flex-col gap-2 mb-3" v-if="isEdit">
<input
v-model="taskLocal.title"
type="text"
class="p-1 text-center rounded-md"
/>
<select v-model="taskLocal.state" class="text-center p-1">
<option value="important">Important</option>
<option value="dontForget">Don't Forget</option>
</select>
<button
#click.prevent="editTask(taskLocal)"
class="p-2 bg-blue-400 rounded-xl"
>
edit
</button>
</div>
</transition>
<div
class="flex justify-between mb-2 shadow-2xl gap-2 bg-gradient-to-r from-white to-slate-300 rounded-xl items-center p-3 pt-6 relative"
>
<div class="absolute -ml-2 top-0 flex left-0 right-0 justify-between">
<PaperClipIcon class="w-9 -mt-3" />
<p class="underline decoration-solid break-all text-rose-400 text-xs">
Created At:
{{ new Date(task.created_at as any as Date).toLocaleDateString() }}
</p>
<div class="flex gap-2">
<PencilSquareIcon
#click.prevent="isEdit = !isEdit"
class="w-5 text-black hover:text-blue-400 cursor-pointer"
/>
<XMarkIcon
#click.prevent="removeScreen = !removeScreen"
class="w-6 hover:text-red-400 cursor-pointer"
/>
</div>
</div>
<ExclamationCircleIcon
class="w-6 h-6 text-center"
:class="[task.state === 'important' ? 'text-red-600' : 'text-green-600']"
/>
<p
class="transition-all flex-1 duration-1000 ease-in-out break-all text-center text-xl"
:class="[
task.isChecked ? ['line-through', 'text-slate-400'] : 'text-slate-700',
]"
>
{{ task.title }}
</p>
<CheckIcon
v-model="taskLocal.isChecked"
#click.prevent="taskCheck(taskLocal)"
class="w-8 h-8 text-center transition-all rounded-full hover:bg-green-300 duration-500 ease-in-out cursor-pointer"
:class="[taskLocal.isChecked ? 'text-green-600' : 'text-gray-400']"
/>
</div>
<transition
enter-active-class="transform transition duration-1000 ease-in-out"
enter-from-class="-translate-y-1/2 opacity-0 scale-y-0"
enter-to-class="translate-y-0 opacity-100 scale-y-100"
leave-active-class="transform transition duration-500 ease-in-out"
leave-from-class="translate-y-0 opacity-100 scale-y-100"
leave-to-class="-translate-y-1/2 opacity-00 scale-y-0"
>
<div
class="flex flex-col p-1 bg-white rounded-xl items-center"
v-if="removeScreen"
>
<h1 class="text-rose-400 text-center">Remove Task</h1>
<p class="text-slate-400">Task will be removed! Are you sure?</p>
<div class="flex gap-2">
<button
#click.prevent="removeScreen = !removeScreen"
class="p-1 px-4 rounded-xl bg-red-600"
>
No
</button>
<button
#click.prevent="removeTask(task.id as any as number)"
class="p-1 px-4 rounded-xl bg-green-600"
>
Yes
</button>
</div>
</div>
</transition>
I tried already existing problems but couldn't find any solution for my problem.

Tailwind - keep header and left/right sidebar sticky on scroll

How do I keep my header, left/right sidebar sticky on scroll (on desktop, not mobile)?
It doesn't seem to be working with the fixed or sticky class, I've posted an example here: https://play.tailwindcss.com/Bj68nUJj1C.
<!-- Background color split screen for large screens -->
<div class="fixed top-0 left-0 h-full w-1/2 bg-white" aria-hidden="true"></div>
<div class="fixed top-0 right-0 h-full w-1/2 bg-gray-50" aria-hidden="true"></div>
<div class="relative flex min-h-screen flex-col">
<!-- Navbar -->
<nav class="flex-shrink-0 bg-indigo-600">
<div class="mx-auto max-w-7xl px-2 sm:px-4 lg:px-8">
<div class="relative flex h-16 items-center justify-between">
<!-- Logo section -->
<div class="flex items-center px-2 lg:px-0 xl:w-64">
<div class="flex-shrink-0">
<img class="h-8 w-auto" src="https://tailwindui.com/img/logos/workflow-mark.svg?color=indigo&shade=300" alt="Workflow" />
</div>
</div>
<!-- Search section -->
<div class="flex flex-1 justify-center lg:justify-end">
<div class="w-full px-2 lg:px-6">
<label for="search" class="sr-only">Search projects</label>
<div class="relative text-indigo-200 focus-within:text-gray-400">
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
<!-- Heroicon name: mini/magnifying-glass -->
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z" clip-rule="evenodd" />
</svg>
</div>
<input id="search" name="search" class="block w-full rounded-md border border-transparent bg-indigo-400 bg-opacity-25 py-2 pl-10 pr-3 leading-5 text-indigo-100 placeholder-indigo-200 focus:bg-white focus:text-gray-900 focus:placeholder-gray-400 focus:outline-none focus:ring-0 sm:text-sm" placeholder="Search projects" type="search" />
</div>
</div>
</div>
<div class="flex lg:hidden">
<!-- Mobile menu button -->
<button type="button" class="inline-flex items-center justify-center rounded-md bg-indigo-600 p-2 text-indigo-400 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-indigo-600" aria-controls="mobile-menu" aria-expanded="false">
<span class="sr-only">Open main menu</span>
<!--
Icon when menu is closed.
Heroicon name: outline/bars-3-center-left
Menu open: "hidden", Menu closed: "block"
-->
<svg class="block h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12H12m-8.25 5.25h16.5" />
</svg>
<!--
Icon when menu is open.
Heroicon name: outline/x-mark
Menu open: "block", Menu closed: "hidden"
-->
<svg class="hidden h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<!-- Links section -->
<div class="hidden lg:block lg:w-80">
<div class="flex items-center justify-end">
<div class="flex">
Documentation
Support
</div>
<!-- Profile dropdown -->
<div class="relative ml-4 flex-shrink-0">
<div>
<button type="button" class="flex rounded-full bg-indigo-700 text-sm text-white focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-indigo-700" id="user-menu-button" aria-expanded="false" aria-haspopup="true">
<span class="sr-only">Open user menu</span>
<img class="h-8 w-8 rounded-full" src="https://images.unsplash.com/photo-1517365830460-955ce3ccd263?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=256&h=256&q=80" alt="" />
</button>
</div>
<!--
Dropdown menu, show/hide based on menu state.
Entering: "transition ease-out duration-100"
From: "transform opacity-0 scale-95"
To: "transform opacity-100 scale-100"
Leaving: "transition ease-in duration-75"
From: "transform opacity-100 scale-100"
To: "transform opacity-0 scale-95"
-->
<div class="absolute right-0 z-10 mt-2 w-48 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="user-menu-button" tabindex="-1">
<!-- Active: "bg-gray-100", Not Active: "" -->
View Profile
Settings
Logout
</div>
</div>
</div>
</div>
</div>
</div>
</nav>
<!-- 3 column wrapper -->
<div class="mx-auto w-full max-w-7xl flex-grow lg:flex xl:px-8">
<!-- Left sidebar & main wrapper -->
<div class="min-w-0 flex-1 bg-white xl:flex">
<div class="border-b border-gray-200 bg-white xl:w-64 xl:flex-shrink-0 xl:border-b-0 xl:border-r xl:border-gray-200">
<div class="h-full py-6 pl-4 pr-6 sm:pl-6 lg:pl-8 xl:pl-0">
<!-- Start left column area -->
<div class="relative h-full" style="min-height: 12rem">
<div class="absolute inset-0 rounded-lg border-2 border-dashed border-gray-200"></div>
</div>
<!-- End left column area -->
</div>
</div>
<div class="bg-white lg:min-w-0 lg:flex-1">
<div class="h-full py-6 px-4 sm:px-6 lg:px-8">
<!-- Start main area-->
<div class="relative h-full" style="min-height: 36rem">
<div class="absolute inset-0 rounded-lg border-2 border-dashed border-gray-200"></div>
</div>
<!-- End main area -->
</div>
</div>
</div>
<div class="bg-gray-50 pr-4 sm:pr-6 lg:flex-shrink-0 lg:border-l lg:border-gray-200 lg:pr-8 xl:pr-0">
<div class="h-full py-6 pl-6 lg:w-80">
<!-- Start right column area -->
<div class="relative h-full" style="min-height: 16rem">
<div class="absolute inset-0 rounded-lg border-2 border-dashed border-gray-200"></div>
</div>
<!-- End right column area -->
</div>
</div>
</div>
</div>
You need to use top-X class together with sticky. For navbar sticky top-0 and for sidebar something like sticky top-20 should work.
Prefix it with corresponding breakpoint prefix to apply it only for bigger screens.
You can try using grid instead of flex and change your layout a bit to achieve this.
<script src="https://cdn.tailwindcss.com"></script>
<div class="fixed top-0 left-0 h-full w-1/2 bg-white" aria-hidden="true"></div>
<div class="fixed top-0 right-0 h-full w-1/2 bg-gray-50" aria-hidden="true"></div>
<div class="relative grid grid-cols-[2rem_1fr_2rem] xl:grid-cols-[minmax(2rem,1fr)_16rem_minmax(200px,calc(80rem-32rem))_16rem_minmax(2rem,1fr)] lg:grid-cols-[2rem_minmax(200px,calc(100%-16rem))_16rem_2rem] min-h-screen">
<!-- Navbar -->
<nav class="min-h-[4rem] sticky top-0 z-10 col-[1/-1] row-[1] flex justify-center items-center bg-indigo-600 text-white">
Nav
</nav>
<aside class="max-h-screen xl:sticky lg:static top-12 col-[2] row-[2] border-b border-gray-200 bg-white xl:border-b-0 xl:border-r xl:border-gray-200">
<div class="h-full py-6 pl-4 pr-6 sm:pl-6 lg:pl-8 xl:pl-0">
<!-- Start left column area -->
<div class="relative h-full" style="min-height: 12rem">
<div class="absolute inset-0 rounded-lg border-2 border-dashed border-gray-200 flex justify-center items-center">
Aside
</div>
</div>
<!-- End left column area -->
</div>
</aside>
<main class="bg-white col-[2] row[3] xl:col-[3] xl:row-[2] min-h-[150vh]">
<div class="h-full py-6 px-4 sm:px-6 lg:px-8">
<!-- Start main area-->
<div class="relative h-full" style="min-height: 36rem">
<div class="absolute inset-0 rounded-lg border-2 border-dashed border-gray-200 flex justify-center items-center">
Main
</div>
</div>
<!-- End main area -->
</div>
</main>
<aside class="max-h-screen sticky top-12 col-[2] row-[4] xl:col-[4] xl:row-[2] lg:col-[3] lg:row-[2/2_span] bg-gray-50 pr-4 sm:pr-6 lg:border-l lg:border-gray-200 lg:pr-8 xl:pr-0">
<div class="h-full py-6 pl-6">
<!-- Start right column area -->
<div class="relative h-full" style="min-height: 16rem">
<div class="absolute inset-0 rounded-lg border-2 border-dashed border-gray-200 flex justify-center items-center">
Aside
</div>
</div>
<!-- End right column area -->
</div>
</aside>
</div>
I try to solve your problem,
you can check here

Mobile menu toggle onclick

I have this html to display a menu and also the mobile version of the menu, however the mobile version is not working, do you know what is necessary to only show the menu on button click and also close the menu on button click? As it is on the mobile version the menu already appears open with the button to close but the button dont hide the menu.
HTML:
<span class="text-xl text-3xl font-bold">logo</span>
</div>
<div class="-mr-2 flex items-center md:hidden">
<button type="button" class="bg-white rounded-md p-2 inline-flex items-center justify-center text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500" aria-expanded="false">
<span class="sr-only">Open main menu</span>
</button>
</div>
</div>
</div>
<div class="hidden md:block md:ml-10 mt-2 md:pr-4 md:space-x-8">
Link 1
Link 2
</div>
</nav>
</div>
<div class="absolute top-0 inset-x-0 p-2 transition transform origin-top-right md:hidden">
<div class="rounded-lg shadow-md bg-white ring-1 ring-black ring-opacity-5 overflow-hidden">
<div class="px-5 pt-4 flex items-center justify-between">
<div class="flex">
<span class="text-xl text-3xl font-bold text-gray-600">logo</span>
</div>
<div class="-mr-2">
<button type="button" class="bg-white rounded-md p-2 inline-flex items-center justify-center text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500">
<span class="sr-only">Close main menu</span>
<svg class="h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
</div>
<div class="px-2 pt-2 pb-3 space-y-1">
Link 1
Link 2
Link 3
</div>
</div>
</div>
<main class="mt-10 mx-auto max-w-7xl px-4 sm:mt-12 sm:px-6 md:mt-16 lg:mt-20 lg:px-8 xl:mt-28">
<div class="sm:text-center lg:text-left">
<h1 class="text-4xl tracking-tight font-extrabold text-gray-600 sm:text-5xl md:text-6xl">
<span class="block xl:inline">Test</span>
</h1>
</div>
</main>
</div>
</div>
<div class="lg:absolute lg:inset-y-0 lg:right-0 lg:w-1/2">
<img class="h-56 w-full object-cover sm:h-72 md:h-96 lg:w-full lg:h-full" src="https://images.unsplash.com/" alt="">
</div>
</div>
You will have to use some javascript to achieve this.
On your mobile navigation you'll want to do this:
<button id="toggle-mobile-nav-btn">Toggle nav</button>
<nav id="mobile-nav" class="hidden">
<!-- Nav content -->
</nav>
Then, in js, you'll want to create an event listener that will run when a user makes a click event on the toggle button.
(I wrapped that in a DOMContentLoaded eventlistener, to make sure the entire DOM is loaded before executing the script).
document.addEventListener('DOMContentLoaded', () => {
const nav = document.querySelector('#mobile-nav');
const toggleBtn = document.querySelector('#toggle-mobile-nav-btn');
toggleBtn.addEventListener('click', () => {
// On click, we toggle the hidden class on the navigation
nav.classList.toggle('hidden');
console.log('Nav toggled!);
});
})
This should toggle your navigation.
You can create a custom css class (instead of Tailwind's hidden class) to add transitions to your navigation. That way, you can add nice effects like sliding etc.

Problem with stacking of elements in tailwindcss

I have a web page styled with tailwindcss that also uses glide.js to create a carousel element. I have a mobile menu triggered by a hamburger button but the resulting menu renders below the glide.js element. I have tried making elements relative and absolute in multiple combinations and also tried static on the carousel element. I have also tried z indexing the elemnts but I cant get my popup menu to render over the glide.js carousel.
Here is a fiddle which if viewed at 616 px width demonstrates my issue.
JS Fiddle Link
<div x-data="{ open: false, menu: false }" class="mt-4 relative bg-white overflow-hidden">
<div class="relative max-w-screen-xl mx-auto">
<div class="relative z-10 pb-8 bg-blue-100 sm:pb-16 md:pb-20 lg:max-w-2xl lg:w-full lg:pb-6 xl:pb-8">
<div class="pt-2 px-4 sm:px-6 lg:px-8">
<nav class="relative flex items-center sm:h-10 justify-start">
<div class="flex items-center flex-grow flex-shrink-0 lg:flex-grow-0">
<div class="flex items-center justify-between w-full lg:w-auto mt-4">
<div class="-mr-2 items-center lg:hidden">
<button #click="open = true" type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out">
<svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
</div>
<img class="lg:hidden" width="100" height="50" src="{{asset('images/epslogo.png')}}" alt="">
</div>
</div>
<div class="hidden lg:flex lg:items-center lg:block lg:mt-4">
<a href="/" class="font-medium text-gray-500 hover:text-gray-900 focus:outline-none focus:text-gray-900 transition duration-150 ease-in-out">
<input width="100" height="50" type="image" src="{{asset('images/EPSnav.png')}}" alt="EPS Logo">
</a>
High Voltage
Low Voltage
EV Charge Points
More...
<div x-show.transition.duration.600ms="menu" #click.away="menu = false" class="z-10 absolute ml-24 top-12 right-0 py-2 bg-white rounded shadow-2xl" >
<a class="block px-4 py-2 text-gray-700 hover:text-white hover:bg-gray-700"
href="#">
Maintenance and Inspection
</a>
<a class="block px-4 py-2 text-gray-700 hover:text-white hover:bg-gray-700"
href="/design">
Design Services
</a>
<a class="block px-4 py-2 text-gray-700 hover:text-white hover:bg-gray-700"
href="#">
Senior Authorised Personnel
</a>
<a class="block px-4 py-2 text-gray-700 hover:text-white hover:bg-gray-700"
href="/contact">
Contact Us
</a>
<a class="block px-4 py-2 text-gray-700 hover:text-white hover:bg-gray-700"
href="#">
About Us
</a>
</div>
</div>
</nav>
</div>
<div
x-show="open"
x-transition:enter="duration-150 ease-out"
x-transition:enter-start="opacity-0 scale-95"
x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="duration-100 ease-in"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-95"
class="absolute top-0 inset-x-0 p-2 transition transform origin-top-right z-50"
>
<div class="relative rounded-lg bg-white shadow-xs overflow-hidden">
<div class="px-5 pt-4 flex items-center justify-between">
<div class="-mr-2">
<button #click="open = false" type="button" class="inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out">
<svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<img class="ml-2" width="100" height="50" src="{{asset('images/epslogo.png')}}" alt="">
</div>
<div class="relative px-2 pt-2 pb-3">
Home
High Voltage
Low Voltage
EV Charge Points
Maintenance and Inspection
Design Services
Senior Authorised Personnel
Contact Us
</div>
</div>
</div>
<div class="relative mt-6 mx-auto max-w-screen-xl px-4 sm:mt-12 sm:px-6 md:mt-6 lg:mt-8 lg:px-8 xl:mt-10">
<div class="text-center lg:text-left">
<h1 class="text-5xl text-gray-700 font-bold">Electrical Power Solutions</h1>
{{-- <img class="h-32 mx-auto mb-4 lg:mx-0" src="{{asset('images/epslogo.png')}}" alt="EPS Logo">--}}
<h2 class="text-indigo-400 text-4xl">Over {{now()->year - 2005}} years of Experience.</h2>
<p class="mt-2 text-base text-gray-500 sm:mt-4 sm:text-lg sm:max-w-xl sm:mx-auto md:mt-2 md:text-xl lg:mx-0">
Supplying High and Low voltage services to the Energy Sector for over {{now()->year - 2005}} years.
</p>
<div class="mt-6">
<a href="/contact" class="text-center rounded-lg border border-transparent bg-indigo-600 px-1 py-1 text-xl leading-6 font-medium text-white hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:shadow-outline-indigo transition ease-in-out duration-150">
Contact Us
</a>
</div>
</div>
</div>
<svg class="hidden lg:block absolute right-0 inset-y-0 h-full w-48 text-blue-200 transform translate-x-1/2" fill="currentColor" viewBox="0 0 100 100" preserveAspectRatio="none">
<polygon points="50,0 100,0 50,100 0,100" />
</svg>
</div>
</div>
<div class="hidden lg:block lg:absolute lg:inset-y-0 lg:right-0 lg:w-1/2">
<img class="h-56 w-full object-cover sm:h-72 md:h-96 lg:w-full lg:h-full" src="{{asset('images/high-voltage.jpg')}}" alt="" />
</div>
</div>
{{--Carousel Heading with standard nav --}}
<div class="hidden lg:block lg:mt-1 lg:mb-1">
<div class="glide">
<div class="glide__track" data-glide-el="track">
<ul class="glide__slides">
<li class="glide__slide">
<div class="block w-full text-white text-5xl text-center">
<img class="object-cover" src='/images/hv.jpg' alt="High Voltage Pylons Picture">
</div>
</li>
<li class="glide__slide">
<div class="block w-full text-white text-5xl text-center">
<img class="object-cover" src='/images/design.jpg' alt="Rolled up design documents">
</div>
</li>
<li class="glide__slide">
<div class="block w-full text-white text-5xl text-center">
<img class="object-cover" src='/images/rope.jpg' alt="Rope access personnel at work">
</div>
</li>
<li class="glide__slide">
<div class="block w-full text-white text-5xl text-center">
<img class="object-cover" src='/images/WTS.jpg' alt="Wind turbines at sunset">
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="lg:hidden">
<div class="glide1">
<div class="glide__track" data-glide-el="track">
<ul class="glide__slides">
<li class="glide__slide">
<div class="block w-full text-white text-5xl text-center">
<img class="object-cover" src='/images/hv.jpg' alt="High Voltage Pylons Picture">
</div>
</li>
<li class="glide__slide">
<div class="block w-full text-white text-5xl text-center">
<img class="object-cover" src='/images/design.jpg' alt="Rolled up design documents">
</div>
</li>
<li class="glide__slide">
<div class="block w-full text-white text-5xl text-center">
<img class="object-cover" src='/images/rope.jpg' alt="Rope access personnel at work">
</div>
</li>
<li class="glide__slide">
<div class="block w-full text-white text-5xl text-center">
<img class="object-cover" src='/images/WTS.jpg' alt="Wind turbines at sunset">
</div>
</li>
</ul>
</div>
</div>
</div>
Any help is appreciated.
Problem is not with slider, z-index, absolute etc, but in fact that you intentionally putted "overflow-hidden" on menu container. Because of this menu that is bigger than its container is "cutted". To test this you can actually remove all content from below (including glide) and keep only menu (header) - problem will still remain.
So replace this:
<div x-data="{ open: false, menu: false }" class="mt-4 relative bg-white overflow-hidden">
with:
<div x-data="{ open: false, menu: false }" class="mt-4 relative bg-white">
Fiddle: https://jsfiddle.net/39d6qhg5/
More info about overflow:
https://www.w3schools.com/cssref/pr_pos_overflow.asp
https://tailwindcss.com/docs/overflow/

Relative element overlaps earlier absolute element

I'm having trouble positioning elements using tailwind. I currently have a submenu positioned absolute. Beneath this element, I have a search bar, who's parent is positioned relative, and the element itself is positioned absolute. This is so that the search icon can ble displayed in the middle of the input.
When the submenu is open, the search bar overlaps the submenu.
Image
Already tried
I've tried positioning the elements in another way, switching between the different positions. I've also tried setting z-indexes to the elements in question.
Html
<div>
<nav>
<!-- other navbar code -->
<div class="block">
<div class="hidden sm:block">
<a href="#" class="flex items-center font-medium text-base text-gray-500 hover:text-gray-900 sm:mt-0 sm:text-xs sm:block">
<svg class="h-5 mr-2 fill-current h-5 mr-2 fill-current sm:block sm:m-auto" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<!-- path -->
</svg>
Name
</a>
</div>
<div class="sm:absolute sm:right-0 sm:mr-5 sm:bg-white sm:rounded sm:shadow"> <!-- needs to be absolute to not mess ut rest of navbar -->
<div class="border-t border-gray-300 sm:border-none">
<div class="px-5 py-5">
<span class="text-xs uppercase tracking-wider text-gray-500 font-semibold">Daniel Kjellid</span>
Action
</div>
</div>
<div class="border-t border-gray-300">
<div class="px-5 py-5">
<span class="text-xs uppercase tracking-wider text-gray-500 font-semibold">Administrator</span>
Another action
</div>
</div>
<button class="w-full text-center py-4 text-gray-900 font-medium bg-gray-200 hover:bg-gray-300">
Logg ut
</button>
</div>
</div>
</nav>
</div>
<div class="bg-white px-5 py-3 flex justify-between items-center border-b border-gray-300">
<div class="relative mr-3 w-full"> <!-- needs to be relative to position svg inside input -->
<div class="absolute inset-y-0 left-0 flex items-center pl-3">
<svg class="h-6 w-6 fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<!-- path -->
</svg>
</div>
<input type="text" class="form-input pl-10 py-2 rounded-lg bg-gray-300 text-gray-600 block w-full" placeholder="Søk blant hundrevis av varer">
</div>
<button class="open-filter-btn bg-gray-300 py-2 px-4 rounded-lg text-gray-600 flex items-center font-medium" type="button">
<svg class="filter-closed-icn h-5 w-5 fill-current mr-2" viewBox="0 0 18 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<!-- path -->
</svg>
<svg class="filter-open-icn h-6 fill-current text-gray-600 hidden" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<!-- path -->
</svg>
Filter
</button>
</div>

Resources