NAVBAR с логотипом CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Humburger Menu</title>
<link rel="stylesheet" href="./style.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css" integrity="sha256-46r060N2LrChLLb5zowXQ72/iKKNiw/lAmygmHExk/o=" crossorigin="anonymous" />
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: "Arial", sans-serif;
}
nav {
background: #000;
color: #fff;
display: flex;
justify-content: space-between;
}
nav .mainMenu {
display: flex;
list-style: none;
}
nav .mainMenu li a {
display: inline-block;
padding: 15px;
text-decoration: none;
text-transform: uppercase;
color: #fff;
font-size: 1.5rem;
}
nav .mainMenu li a:hover {
background: rgb(255, 94, 0);
}
nav .openMenu {
font-size: 2rem;
margin: 20px;
display: none;
cursor: pointer;
}
nav .mainMenu .closeMenu,
.icons i {
font-size: 2rem;
display: none;
cursor: pointer;
}
.fa-facebook:hover {
color: rgb(0, 110, 255);
}
.fa-twitter:hover {
color: rgb(86, 154, 243);
}
.fa-instagram:hover {
color: rgb(255, 0, 191);
}
.fa-github:hover {
color: rgb(255, 123, 0);
}
nav .logo {
margin: 6px;
font-size: 25px;
cursor: pointer;
}
@media (max-width: 800px) {
nav .mainMenu {
height: 100vh;
position: fixed;
top: 0;
right: 0;
left: 0;
z-index: 10;
flex-direction: column;
justify-content: center;
align-items: center;
background: #000;
transition: top 1s ease;
display: none;
}
nav .mainMenu .closeMenu {
display: block;
position: absolute;
top: 20px;
right: 20px;
}
nav .openMenu {
display: block;
}
nav .mainMenu li a:hover {
background: none;
color: rgb(255, 123, 0);
font-size: 1.6rem;
}
.icons i {
display: inline-block;
padding: 12px;
}
}
</style>
</head>
<body>
<nav>
<div class="logo">
<h1>Brand Name</h1>
</div>
<div class="openMenu"><i class="fa fa-bars"></i></div>
<ul class="mainMenu">
<li><a href="#">Home</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
<div class="closeMenu"><i class="fa fa-times"></i></div>
<span class="icons">
<i class="fab fa-facebook"></i>
<i class="fab fa-instagram"></i>
<i class="fab fa-twitter"></i>
<i class="fab fa-github"></i>
</span>
</ul>
</nav>
<script>
// this is the script here
const mainMenu = document.querySelector(".mainMenu");
const closeMenu = document.querySelector(".closeMenu");
const openMenu = document.querySelector(".openMenu");
openMenu.addEventListener("click", show);
closeMenu.addEventListener("click", close);
function show() {
mainMenu.style.display = "flex";
mainMenu.style.top = "0";
}
function close() {
mainMenu.style.top = "-100%";
}
</script>
</body>
</html>
Better Bee