-
Notifications
You must be signed in to change notification settings - Fork 3
/
hover-dropdown-menu.html
52 lines (51 loc) · 2.4 KB
/
hover-dropdown-menu.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hover Dropdown</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="//unpkg.com/alpinejs" defer></script>
</head>
<style>
[x-cloak] {display: none !important;}
</style>
<body>
<!-- Layout -->
<div class="flex items-center justify-center h-screen bg-gray-200">
<!-- Dropdown 1 -->
<div x-cloak x-data="{ open: false }" @mouseleave="open = false" class="relative inline-block">
<!-- Dropdown Toggle Button -->
<button @mouseover="open = true" class="flex items-center px-3 py-2 bg-white rounded-lg">
<span class="mr-4">Hover Dropdown</span>
<span
:class="open = ! open ? '' : '-rotate-180'"
class="transition-transform duration-500 transform">
<svg class="w-4 h-4 fill-current" 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>
<!-- End Dropdown Toggle Button -->
<!-- Dropdown Menu -->
<div x-show="open"
x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0 transform scale-90"
x-transition:enter-end="opacity-100 transform scale-100"
x-transition:leave="transition ease-in duration-300"
x-transition:leave-start="opacity-100 transform scale-100"
x-transition:leave-end="opacity-0 transform scale-90"
class="absolute right-0 py-1 text-gray-500 bg-white rounded-lg shadow-xl w-96">
<a href="#" class="block px-4 py-1 hover:text-blue-400">Tailwind</a>
<a href="#" class="block px-4 py-1 hover:text-blue-400">Alpine</a>
<a href="#" class="block px-4 py-1 hover:text-blue-400">Laravel</a>
<a href="#" class="block px-4 py-1 hover:text-blue-400">Livewire</a>
</div>
<!-- End Dropdown Menu -->
</div>
<!-- End Dropdown 1 -->
</div>
<!-- End Layout -->
</body>
</html>