Displays a hamburger menu that transforms into a cross button on hover.
Use a container with top, bottom and middle bars. .hamburger-menudiv
Set the container to with . display: flexflex-flow: column wrap
Use to add distance between bars. justify-content: space-between
Used to rotate the top and bottom bars 45 degrees and fade the middle bar on hover. transform: rotate()opacity: 0
Use to rotate the bar around the left point. transform-origin: left
<div class="hamburger-menu">
<div class="bar top"></div>
<div class="bar middle"></div>
<div class="bar bottom"></div>
</div>
.hamburger-menu {
display: flex;
flex-flow: column wrap;
justify-content: space-between;
height: 2.5rem;
width: 2.5rem;
cursor: pointer;
}
.hamburger-menu .bar {
height: 5px;
background: black;
border-radius: 5px;
margin: 3px 0px;
transform-origin: left;
transition: all 0.5s;
}
.hamburger-menu:hover .top {
transform: rotate(45deg);
}
.hamburger-menu:hover .middle {
opacity: 0;
}
.hamburger-menu:hover .bottom {
transform: rotate(-45deg);
}