I am trying to make a navbar menu item by using tailwind, here is the some snippet of the code
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<li class="w-22 hover:border-gray-700 border-transparent border-b-2 cursor-pointer">
<a href="#">New & Featured</a>
<ul class="absolute hidden left-2 mt-2 py-2 w-48 bg-white rounded-lg shadow-xl">
<li class="block px-4 py-2 text-gray-800 hover:bg-indigo-600">Laptops</li>
<li class="block px-4 py-2 text-gray-800 hover:bg-indigo-600"><a href="#">Monitors</a></li>
<li class="block px-4 py-2 text-gray-800 hover:bg-indigo-600"><a href="#">Printers</a></li>
</ul>
</li>
</body>
</html>
I would like that when I hover on the element News & Features the drop down element element is seen, when I hover out it should return to its default hidden.
>Solution :
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<style>
.dropdown:hover .dropdown-menu {
display: block;
}
.dropdown-menu {
display: none;
}
</style>
</head>
<body>
<nav>
<ul>
<li class="relative dropdown">
<a href="#" class="inline-block">New & Featured</a>
<ul class="absolute left-0 w-48 py-2 bg-white rounded-lg shadow-xl dropdown-menu">
<li class="block px-4 py-2 text-gray-800 hover:bg-indigo-600">Laptops</li>
<li class="block px-4 py-2 text-gray-800 hover:bg-indigo-600"><a href="#">Monitors</a></li>
<li class="block px-4 py-2 text-gray-800 hover:bg-indigo-600"><a href="#">Printers</a></li>
</ul>
</li>
</ul>
</nav>
</body>
</html>