<div class="container">
<div class="menu_icon">
<span class="one"></span>
<span class="two"></span>
<span class="three"></span>
</label>
</div>
</div>
<!-- Method used -->
<!-- I moved the first line to 25px in the y axis, rotate it 45 deg, second line's opacity is set to zero, and finally the third line is moved 25px in the y axis, rotate it -45 deg, -->
* {
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;
background-color: #fff;
transform: rotate(0);
transition: all 200ms cubic-bezier(0.895, 0.03, 0.685, 0.22);
}
span.one {
top: 0px;
}
span.two {
top: 25px;
}
span.three {
top: 50px;
}
.clicked .one {
transform: translateY(25px) rotate(45deg);
}
.clicked .two {
opacity: 0;
}
.clicked .three {
transform: translateY(-25px) rotate(-45deg);
}
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.