Modern 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>Modern Navigation Bar</title> <style> @import url('https://fonts.googleapis.com/css2?family=Roboto: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: 'Roboto', sans-serif; margin: 0; background: #f5f5f5; } .navbar { background: #333; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; position: fixed; width: 100%; top: 0; z-index: 1000; } .navbar .logo { font-size: 1.5em; color: #fff; font-weight: bold; } .navbar ul { list-style: none; display: flex; margin: 0; margin-right: 100px; 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:after { content: ''; position: absolute; width: 0; height: 2px; background: #ff6f61; left: 0; bottom: -4px; transition: width 0.3s; } .navbar ul li a:hover:after { width: 100%; } .menu-btn { display: none; font-size: 2em; color: #fff; cursor: pointer; margin-right: 60px; } @media (max-width: 768px) { .navbar ul { position: absolute; top: 60px; left: -100%; background: #333; width: 100%; flex-direction: column; align-items: center; transition: left 0.3s ease; } .navbar ul li { margin: 15px 0; } .menu-btn { display: block; } .navbar ul.active { left: 0; } } </style> </head> <body> <nav class="navbar"> <div class="logo">Modern</div> <ul> <li><a href="#">Home</a></li> <li><a href="#">Features</a></li> <li><a href="#">Pricing</a></li> <li><a href="#">Contact</a></li> </ul> <div class="menu-btn"> <i class="fa fa-bars"></i> </div> </nav> <script> document.querySelector('.menu-btn').addEventListener('click', () => { document.querySelector('.navbar ul').classList.toggle('active'); }); </script> </body> </html>