Navbar #1 | Responsive Flexbox Navigation Bar with Logo
- On the body, use this emet and click `tab`
.top-bar>span>ul>li*3>a
3. Use google fonts (Poppins - Google Fonts)
4. Use jquery cdn
html code
<!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="styles.css">
<script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
<title>Document</title>
</head>
<body>
<!-- generate with `.top-bar>span+ul>li*3>a>ion-icon` -->
<div class="top-bar">
<span><ion-icon name="call-outline"></ion-icon> 111 222 333 444</span>
<ul>
<li><a href="#"><ion-icon name="logo-facebook"></ion-icon></a></li>
<li><a href="#"><ion-icon name="logo-twitter"></ion-icon></a></li>
<li><a href="#"><ion-icon name="logo-instagram"></ion-icon></a></li>
</ul>
</div>
<!-- generate with `nav>.logo>a+.toggle+ul.menu>li*5>a` -->
<nav>
<div class="logo">
<a href=""><img src="logo.png" alt="Logo">Logo</a>
</div>
<div class="toggle">
<a href="#"><ion-icon name="menu-outline"></ion-icon></a>
</div>
<ul class="menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
$(function(){
$(".toggle").on("click", function(){
if ($(".menu").hasClass("active")) {
$(".menu").removeClass("active");
$(this).find("a").html("<ion-icon name='menu-outline'></ion-icon>");
} else {
$(".menu").addClass("active");
$(this).find("a").html("<ion-icon name='close-outline'></ion-icon>");
}
})
})
</script>
</body>
</html>
css code
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: "Poppins", sans-serif; } a, a:hover { text-decoration: none; } .top-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px; background: #ef4b3f; } .top-bar span { color: #fff; } .top-bar ul { list-style: none; display: flex; } .top-bar li { margin: 0 5px; } .top-bar a { color: #fff; } .top-bar a:hover { color: #f9c23c; } nav { display: flex; align-items: center; background-color: #222; padding: 5px 20px; } nav a { color: #fff; } nav a:hover { color: #ef4b3f; } .logo { flex: 1; } .logo a { display: flex; align-items: center; font-size: 20px; } .logo a:hover { color: #fff; } .logo img{ width: 40px; margin-right: 10px; } .menu { display: flex; list-style: none; align-items: center; } .menu li { padding: 15px 10px; font-size: 16px; } .toggle { font-size: 30px; display: none; color: #fff; } @media screen and (max-width: 600px) { nav { display: block; position: relative; padding: 15px 20px; } .menu { margin-top: 15px; display: none; } .menu.active, .toggle { display: block; } .toggle { position: absolute; top: 15px; right: 20px; } }
image,
logo.png
Komentar
Posting Komentar
i wanna hear your comment