<div class="container">
<div class="menu_icon">
<span class="one"></span>
<span class="two">
<span></span>
<span></span>
</span>
<span class="three"></span>
</label>
</div>
</div>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.container {
height: 100vh;
width: 100vw;
overflow: hidden;
background: #485563;
background: -webkit-linear-gradient(to right, #29323c, #485563);
background: linear-gradient(to right, #29323c, #485563);
display: flex;
justify-content: center;
align-items: center;
}
.menu_icon {
width: 55px;
height: 55px;
margin: auto;
z-index: 10;
cursor: pointer;
position: relative;
display: flex;
align-items: center;
padding: 5px 0;
}
.menu_icon span {
position: absolute;
display: block;
height: 5px;
width: 60px;
transform: rotate(0);
}
.one,
.three {
background-color: #fff;
}
.two {
width: 60px;
height: 5px;
z-index: 10;
position: relative;
display: flex;
background-color: none;
}
.two span {
position: absolute;
display: block;
height: 5px;
width: 30px;
background-color: #fff;
transform: rotate(0);
}
.two span:nth-child(2) {
right: 0;
}
.two span:nth-child(1),
.two span:nth-child(2) {
transform: translateX(0);
transition: all 200ms 500ms ease;
}
span.one {
top: 0px;
transition: all 200ms cubic-bezier(0.895, 0.03, 0.685, 0.22);
}
span.two {
top: 25px;
transition: all 400ms cubic-bezier(0.895, 0.03, 0.685, 1.92);
}
span.three {
top: 50px;
transition: all 500ms cubic-bezier(0.895, 0.03, 0.685, 0.22);
}
.clicked .one {
transform: translateY(25px) rotate(45deg);
}
.clicked .three {
transform: translateY(-25px) rotate(-45deg);
}
.clicked .two span:nth-child(1) {
transform: translateX(10vw);
background-color: red;
opacity: 0;
}
.clicked .two span:nth-child(2) {
transform: translateX(-10vw);
background-color: red;
opacity: 0;
}
let icon = document.querySelector(".menu_icon");
icon.addEventListener("click", () => {
icon.classList.toggle("clicked");
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.