<div class="wrapper">
<div class="burger">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
<div class="circle"></div>
</div>
<a target="_blank" href="https://dribbble.com/shots/1623679-Open-Close">Inspired by Creativedash's Open & Close animation</a>
@import "compass/css3";
@import "compass/css3/transform";
@mixin transitions($time, $easing, $delay:0s) {
-webkit-transition: all $time $easing $delay;
-moz-transition: all $time $easing $delay;
-ms-transition: all $time $easing $delay;
-o-transition: all $time $easing $delay;
transition: all $time $easing $delay;
}
@mixin animation($name, $time) {
-webkit-animation: $name $time infinite;
-moz-animation: $name $time infinite;
-o-animation: $name $time infinite;
animation: $name $time infinite;
-webkit-animation-direction: alternate;
animation-direction: alternate;
}
@mixin keyframes($name) {
@-webkit-keyframes #{$name} {
@content;
}
@-moz-keyframes #{$name} {
@content;
}
@-ms-keyframes #{$name} {
@content;
}
@keyframes #{$name} {
@content;
}
}
body {
background: #31AA39;
text-align: center;
margin: 0;
padding: 0;
}
a {
color: #fff;
font-family: sans-serif;
text-decoration: none;
&:hover { border-bottom: 2px solid white; }
}
.wrapper {
text-align: center;
margin: 200px auto 50px auto;
}
.burger {
height: 30px;
width: 33px;
cursor: pointer;
margin: 0 auto;
display: block;
.one,
.two,
.three {
margin-top: 3px;
background: #fff;
width: 33px;
height: 4px;
position: absolute;
border-radius: 2px;
@include transitions(0.2s, ease-in-out);
}
.one {
@include animation(layer-one, 2.3333s);
}
.two {
margin-top: 13px;
@include transform-origin(33px,0);
@include animation(layer-two, 2.3333s);
}
.three {
margin-top: 23px;
@include animation(layer-three, 2.3333s);
}
}
// Animation for the top layer
@include keyframes(layer-one) {
0% {
@include simple-transform(1, 0deg, 0, 0);
}
26.5% {
@include simple-transform(1, 0deg, 0, 0);
}
33% {
@include simple-transform(1, 25deg, 0, 0);
}
40% {
@include simple-transform(1, -60deg, 0, 14px);
}
60% {
@include simple-transform(1, -45deg, 0, 14px);
}
100% {
@include simple-transform(1, -45deg, 0, 14px);
}
}
// Animation for the bottom layer
@include keyframes(layer-three) {
0% {
@include simple-transform(1, 0deg, 0, 0);
}
26.5% {
@include simple-transform(1, 0deg, 0, 0);
}
33% {
@include simple-transform(1, -25deg, 0, 0);
}
40% {
@include simple-transform(1, 60deg, 0, -14px);
}
60% {
@include simple-transform(1, 45deg, 0, -14px);
}
100% {
@include simple-transform(1, 45deg, 0, -14px);
}
}
// Animation for the middle layer
@include keyframes(layer-two) {
0% {
@include transform(translateX(0) scaleX(1));
}
26.5% {
@include transform(translateX(0) scaleX(1));
}
33% {
@include transform(translateX(-10px) scaleX(0.95));
}
36.5% {
@include transform(translateX(28px) scaleX(1));
}
44% {
@include transform(translateX(28px) scaleX(0));
}
100% {
@include transform(translateX(28px) scaleX(0));
}
}
// ----------
// CIRCLE
// ----------
.circle {
width: 60px;
height: 60px;
border: 4px solid #fff;
border-radius: 60px;
display: block;
position: absolute;
left: 50%;
margin-left: -25px;
margin-top: -49px;
@include transitions(0.2s, ease-in-out);
@include animation(circle-anim, 2.3333s);
}
@include keyframes(circle-anim) {
0% {
@include transform(rotate(90deg));
clip: rect(0px, 0px, 0px, 0px);
}
26.5% {
@include transform(rotate(90deg));
clip: rect(0px, 0px, 0px, 0px);
}
33% {
@include transform(rotate(90deg));
clip: rect(0px, 0px, 0px, 0px);
}
60% {
@include transform(rotate(120deg));
clip: rect(0px, 35px, 35px, 0px);
}
100% {
@include transform(rotate(-360deg));
clip: rect(auto, auto, auto, auto);
}
}
View Compiled
This Pen doesn't use any external CSS resources.