Get this fully responsive and attractive header with beautiful toggle button and toggle menu for all kinds of websites Free for now. Languages used - HTML, CSS, JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Beautiful Navbar</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100">
<nav class="bg-white shadow-lg">
<div class="max-w-7xl mx-auto px-4">
<div class="flex justify-between items-center py-4">
<!-- Logo -->
<a href="#" class="text-2xl font-bold text-blue-600">Alexis</a>
<!-- Search Bar (Centered) -->
<div class="hidden md:flex flex-grow justify-center">
<input type="text" placeholder="Search..." class="w-96 px-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-400">
</div>
<!-- Menu Items (Hidden on small screens) -->
<div class="hidden md:flex space-x-6">
<a href="#" class="text-gray-700 hover:text-blue-500 transition">Home</a>
<a href="#" class="text-gray-700 hover:text-blue-500 transition">About</a>
<a href="#" class="text-gray-700 hover:text-blue-500 transition">Services</a>
<a href="#" class="text-gray-700 hover:text-blue-500 transition">Contact</a>
</div>
<!-- Mobile Menu Button -->
<button id="menu-btn" class="md:hidden focus:outline-none">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7"></path>
</svg>
</button>
</div>
<!-- Mobile Menu (Initially hidden) -->
<div id="mobile-menu" class="hidden flex flex-col space-y-4 py-4 text-center opacity-0 transform scale-95 transition-all duration-300 ease-in-out">
<a href="#" class="text-gray-700 hover:text-blue-500 transition">Home</a>
<a href="#" class="text-gray-700 hover:text-blue-500 transition">About</a>
<a href="#" class="text-gray-700 hover:text-blue-500 transition">Services</a>
<a href="#" class="text-gray-700 hover:text-blue-500 transition">Contact</a>
</div>
</div>
</nav>
<script>
const menuBtn = document.getElementById('menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
menuBtn.addEventListener('click', () => {
if (mobileMenu.classList.contains('hidden')) {
mobileMenu.classList.remove('hidden');
setTimeout(() => {
mobileMenu.classList.remove('opacity-0', 'transform', 'scale-95');
}, 10);
} else {
mobileMenu.classList.add('opacity-0', 'transform', 'scale-95');
setTimeout(() => {
mobileMenu.classList.add('hidden');
}, 300);
}
});
</script>
</body>
</html>