I am currently developing a CSS animation that is inspired by this. I have made progress and almost reached my goal, but I am facing some difficulties in getting it to work perfectly. For those unable or unwilling to visit the links: I aim to create an animation using CSS that transforms a three-bar menu icon into an X shape. Although I have managed to make the bars overlap and rotate, the symmetry of the strokes is not ideal.
Check out my code below:
<div class="container">
<div class="centerized">
<div class="bar1"> </div>
<div class="bar2"> </div>
<div class="bar3"> </div>
</div>
</div>
Here's my SCSS code snippet:
@keyframes ani1{
0% {margin-bottom: 16%;}
50% {margin-bottom: none; transform: translate(0, 20px);}
100% {margin-bottom: none; transform: rotate(30deg);}
}
@keyframes ani2{
0% {margin-bottom: 16%; opacity: 1;}
75% {margin-bottom: none; opacity: 0;}
100% {margin-bottom: none; opacity: 0;}
}
@keyframes ani3{
0% {margin-bottom: 16%;}
50% {margin-bottom: none; transform: translate(0px, -20px);}
100% {margin-bottom: none; transform: rotate(-30deg);}
}
I suspect that the positioning of elements during the animation might be causing the issue. For a comprehensive view of the code, please click on the provided link above.