Skip to content

Instantly share code, notes, and snippets.

@AlexandrKutsenko
Created May 18, 2018 12:49
Show Gist options
  • Save AlexandrKutsenko/0ecb73e589623f68b9eb26246f2bb832 to your computer and use it in GitHub Desktop.
Save AlexandrKutsenko/0ecb73e589623f68b9eb26246f2bb832 to your computer and use it in GitHub Desktop.
sanwich
body {
background-color: #333;
}
#sandwich {
width: 100px;
height: 100px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.sw-topper {
position: relative;
top: 0;
width: 100px;
height: 10px;
background: #fff;
border: none;
border-radius: 4px 4px 4px 4px;
transition: transform 0.5s, top 0.2s;
/* transition-delay: 0.2s, 0s; */
}
.sw-bottom {
position: relative;
width: 100px;
height: 10px;
top: 20px;
background: #fff;
border: none;
border-radius: 4px 4px 4px 4px;
transition: transform 0.5s, top 0.2s;
transition-delay: 0.2s, 0s;
}
.sw-footer {
position: relative;
width: 100px;
height: 10px;
top: 40px;
background: #fff;
border: none;
border-radius: 4px 4px 4px 4px;
transition: all 0.5s;
transition-delay: 0.1s;
}
#sandwich.active .sw-topper {
top: 15px;
transform: rotate(140deg);
}
#sandwich.active .sw-bottom {
top: 5px;
transform: rotate(-140deg);
}
#sandwich.active .sw-footer {
opacity: 0;
top: 0;
transform: rotate(180deg);
}
<div id='sandwich'>
<div class='sw-topper'></div>
<div class='sw-bottom'></div>
<div class='sw-footer'></div>
</div>
$("#sandwich, .menu_item").click(function() {
$("#sandwich").toggleClass("active");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment