<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div class="icon"></div>
</nav>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
background-color: aliceblue;
height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
font-family: "Montserrat";
font-size: 18px;
}
ul {
background-color: white;
border-radius: 4px;
list-style: none;
display: flex;
align-items: center;
justify-content: center;
box-shadow: -7px 9px 17px 0px #00000017;
}
li a {
display: inline-block;
padding: 10px 20px;
text-decoration: none;
color: black;
}
li:hover a {
color: crimson;
}
nav {
position: relative;
}
.icon {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: -80px;
height: 60px;
width: 60px;
border-radius: 50%;
background-color: rgb(255, 255, 255);
background-image: url(https://cdn-icons-png.flaticon.com/512/1828/1828859.png);
background-position: center;
background-repeat: no-repeat;
background-size: 50%;
cursor: pointer;
box-shadow: 0px 0px 17px 0px #00000017;
transition: 0.5s ease transform;
}
.icon.close {
transform: translateY(-50%) rotate(360deg);
background-image: url(https://cdn-icons-png.flaticon.com/512/2961/2961937.png);
}
ul {
width: 0px;
overflow: hidden;
transform: translateX(50px);
opacity: 0;
pointer-events: none;
transition: 0.5s ease;
padding: 20px;
}
nav.show ul {
width: 450px;
transform: translate(0px);
opacity: 1;
pointer-events: all;
}
nav {
position: absolute;
top: 10px;
right: 100px;
}
@media only screen and (max-width: 768px) {
body {
font-size: 14px;
}
li a {
padding: 5px 10px;
}
nav ul {
padding: 15px;
}
nav.show ul {
width: 260px;
}
.icon {
width: 45px;
height: 45px;
right: -50px;
}
nav {
top: 10px;
right: 60px;
}
}
const icon = document.querySelector(".icon");
const nav = document.querySelector("nav");
icon.addEventListener("click", () => {
icon.classList.toggle("close");
nav.classList.toggle("show");
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.