Stylish Navigation Bar - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" /> <title>Stylish Navigation Bar</title> <style> @import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700&display=swap'); @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css'); body { font-family: 'Nunito', sans-serif; margin: 0; background: #f0f0f0; } .navbar { background: linear-gradient(45deg, #1e3c72, #2a5298); display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); position: fixed; width: 100%; top: 0; z-index: 1000; transition: background 0.3s; } .navbar .logo { font-size: 1.5em; color: #fff; font-weight: bold; display: flex; align-items: center; } .navbar .logo i { margin-right: 10px; animation: rotateIcon 2s infinite linear; } .navbar ul { list-style: none; display: flex; margin: 0; padding: 0; } .navbar ul li { margin: 0 15px; } .navbar ul li a { color: #fff; text-decoration: none; font-size: 1.1em; position: relative; transition: color 0.3s; } .navbar ul li a:before { content: ''; position: absolute; width: 100%; height: 2px; bottom: -6px; left: 0; background-color: #fff; visibility: hidden; transform: scaleX(0); transition: all 0.3s ease-in-out; } .navbar ul li a:hover:before { visibility: visible; transform: scaleX(1); } .navbar ul li a:hover { color: #ffdd57; } .navbar .menu-btn { display: none; font-size: 2em; color: #fff; cursor: pointer; margin-right: 100px; } @keyframes rotateIcon { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes slideIn { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } } @media (max-width: 768px) { .navbar ul { position: absolute; top: 60px; left: -100%; background: #1e3c72; width: 100%; flex-direction: column; align-items: center; transition: left 0.3s ease; } .navbar ul li { margin: 15px 0; } .navbar .menu-btn { display: block; } .navbar ul.active { left: 0; animation: slideIn 0.5s forwards; } } .social-icons{ margin-right: 100px; } /* Additional unique styles */ .navbar .social-icons { display: flex; align-items: center; } .navbar .social-icons a { color: #fff; font-size: 1.2em; margin-left: 15px; transition: color 0.3s; } .navbar .social-icons a:hover { color: #ffdd57; } </style> </head> <body> <nav class="navbar"> <div class="logo"> <i class="fas fa-dragon"></i> MyBrand </div> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Services</a></li> <li><a href="#">Contact</a></li> </ul> <div class="social-icons"> <a href="#" title="Facebook"><i class="fab fa-facebook-f"></i></a> <a href="#" title="Twitter"><i class="fab fa-twitter"></i></a> <a href="#" title="Instagram"><i class="fab fa-instagram"></i></a> </div> <div class="menu-btn"> <i class="fa fa-bars"></i> </div> </nav> <script src="https://kit.fontawesome.com/f2c67a1c6b.js" crossorigin="anonymous"></script> <script> document.querySelector('.menu-btn').addEventListener('click', () => { document.querySelector('.navbar ul').classList.toggle('active'); }); window.addEventListener('scroll', () => { const navbar = document.querySelector('.navbar'); if (window.scrollY > 50) { navbar.style.background = 'linear-gradient(45deg, #2a5298, #1e3c72)'; } else { navbar.style.background = 'linear-gradient(45deg, #1e3c72, #2a5298)'; } }); </script> </body> </html>