A Pen by Emmanuel ADEKPLOVI on CodePen.
Created
August 3, 2022 06:07
-
-
Save manutheblacker/f2b003804868df84d86612d850cc6780 to your computer and use it in GitHub Desktop.
Tailwind Navbar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- navbar goes here --> | |
<nav class="bg-gray-100"> | |
<div class="max-w-6xl mx-auto px-4"> | |
<div class="flex justify-between"> | |
<div class="flex space-x-4"> | |
<!-- logo --> | |
<div> | |
<a href="#" class="flex items-center py-5 px-2 text-gray-700 hover:text-gray-900"> | |
<svg class="h-6 w-6 mr-1 text-blue-400" 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="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" /> | |
</svg> | |
<span class="font-bold">Better Dev</span> | |
</a> | |
</div> | |
<!-- primary nav --> | |
<div class="hidden md:flex items-center space-x-1"> | |
<a href="#" class="py-5 px-3 text-gray-700 hover:text-gray-900">Features</a> | |
<a href="#" class="py-5 px-3 text-gray-700 hover:text-gray-900">Pricing</a> | |
</div> | |
</div> | |
<!-- secondary nav --> | |
<div class="hidden md:flex items-center space-x-1"> | |
<a href="" class="py-5 px-3">Login</a> | |
<a href="" class="py-2 px-3 bg-yellow-400 hover:bg-yellow-300 text-yellow-900 hover:text-yellow-800 rounded transition duration-300">Signup</a> | |
</div> | |
<!-- mobile button goes here --> | |
<div class="md:hidden flex items-center"> | |
<button class="mobile-menu-button"> | |
<svg class="w-6 h-6" 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="M4 6h16M4 12h16M4 18h16" /> | |
</svg> | |
</button> | |
</div> | |
</div> | |
</div> | |
<!-- mobile menu --> | |
<div class="mobile-menu hidden md:hidden"> | |
<a href="#" class="block py-2 px-4 text-sm hover:bg-gray-200">Features</a> | |
<a href="#" class="block py-2 px-4 text-sm hover:bg-gray-200">Pricing</a> | |
</div> | |
</nav> | |
<!-- content goes here --> | |
<div class="py-32 text-center"> | |
<h2 class="font-extrabold text-4xl">Navbars in Tailwind!</h2> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// grab everything we need | |
const btn = document.querySelector("button.mobile-menu-button"); | |
const menu = document.querySelector(".mobile-menu"); | |
// add event listeners | |
btn.addEventListener("click", () => { | |
menu.classList.toggle("hidden"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.0.2/tailwind.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment