Skip to content

Instantly share code, notes, and snippets.

@dawesi
Created June 16, 2018 09:44
Show Gist options
  • Save dawesi/3c6745e22cc1c4ef2754248517f4fad4 to your computer and use it in GitHub Desktop.
Save dawesi/3c6745e22cc1c4ef2754248517f4fad4 to your computer and use it in GitHub Desktop.
Menu Button
<div class="navTrigger">
<i></i><i></i><i></i>
</div>
$('.navTrigger').click(function(){
$(this).toggleClass('active');
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
@import "lesshat";
*{
margin: 0;
padding: 0;
}
body, html{
height: 100%;
background-color: #2FB0B5;
}
.navTrigger {
cursor: pointer;
width: 30px;
height: 25px;
margin: auto;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
i {
background-color: #fff;
border-radius: 2px;
content: '';
display: block;
width: 100%;
height: 4px;
}
i:nth-child(1) {
-webkit-animation:outT 0.8s backwards;
animation:outT 0.8s backwards;
-webkit-animation-direction:reverse;
animation-direction:reverse;
}
i:nth-child(2) {
margin: 5px 0;
-webkit-animation:outM 0.8s backwards;
animation:outM 0.8s backwards;
-webkit-animation-direction:reverse;
animation-direction:reverse;
}
i:nth-child(3) {
-webkit-animation:outBtm 0.8s backwards;
animation:outBtm 0.8s backwards;
-webkit-animation-direction:reverse;
animation-direction:reverse;
}
&.active {
i:nth-child(1) {
-webkit-animation:inT 0.8s forwards;
animation:inT 0.8s forwards;
}
i:nth-child(2) {
-webkit-animation:inM 0.8s forwards;
animation:inM 0.8s forwards;
}
i:nth-child(3) {
-webkit-animation:inBtm 0.8s forwards;
animation:inBtm 0.8s forwards;
}
}
}
@-webkit-keyframes inM{
50%{-webkit-transform:rotate(0deg);}
100%{-webkit-transform:rotate(45deg);}
}
@keyframes inM{
50%{transform:rotate(0deg);}
100%{transform:rotate(45deg);}
}
@-webkit-keyframes outM{
50%{-webkit-transform:rotate(0deg);}
100%{-webkit-transform:rotate(45deg);}
}
@keyframes outM{
50%{transform:rotate(0deg);}
100%{transform:rotate(45deg);}
}
@-webkit-keyframes inT{
0%{-webkit-transform: translateY(0px) rotate(0deg);}
50%{-webkit-transform: translateY(9px) rotate(0deg);}
100%{-webkit-transform: translateY(9px) rotate(135deg);}
}
@keyframes inT{
0%{transform: translateY(0px) rotate(0deg);}
50%{transform: translateY(9px) rotate(0deg);}
100%{transform: translateY(9px) rotate(135deg);}
}
@-webkit-keyframes outT{
0%{-webkit-transform: translateY(0px) rotate(0deg);}
50%{-webkit-transform: translateY(9px) rotate(0deg);}
100%{-webkit-transform: translateY(9px) rotate(135deg);}
}
@keyframes outT{
0%{transform: translateY(0px) rotate(0deg);}
50%{transform: translateY(9px) rotate(0deg);}
100%{transform: translateY(9px) rotate(135deg);}
}
@-webkit-keyframes inBtm{
0%{-webkit-transform: translateY(0px) rotate(0deg);}
50%{-webkit-transform: translateY(-9px) rotate(0deg);}
100%{-webkit-transform: translateY(-9px) rotate(135deg);}
}
@keyframes inBtm{
0%{transform: translateY(0px) rotate(0deg);}
50%{transform: translateY(-9px) rotate(0deg);}
100%{transform: translateY(-9px) rotate(135deg);}
}
@-webkit-keyframes outBtm{
0%{-webkit-transform: translateY(0px) rotate(0deg);}
50%{-webkit-transform: translateY(-9px) rotate(0deg);}
100%{-webkit-transform: translateY(-9px) rotate(135deg);}
}
@keyframes outBtm{
0%{transform: translateY(0px) rotate(0deg);}
50%{transform: translateY(-9px) rotate(0deg);}
100%{transform: translateY(-9px) rotate(135deg);}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment