Skip to content

Instantly share code, notes, and snippets.

@veritstudio
Created August 31, 2018 14:31
Show Gist options
  • Save veritstudio/e99c8fcd43699c9268f236fec679c03e to your computer and use it in GitHub Desktop.
Save veritstudio/e99c8fcd43699c9268f236fec679c03e to your computer and use it in GitHub Desktop.
Animated hamburger icon for mobile
<header>
<div class="nav-toggle">
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</header>
#nav-icon3 {
left: 15px;
position: absolute;
z-index: 14;
width: 19px;
height: 23px;
margin: 16px auto 0;
.lib-rotate(0deg);
-webkit-transition: transfrom .5s ease-in-out;
-moz-transition: transfrom .5s ease-in-out;
-o-transition: transfrom .5s ease-in-out;
transition: transfrom .5s ease-in-out;
cursor: pointer;
}
#nav-icon3 span {
display: block;
position: absolute;
height: 1px;
width: 100%;
border-bottom: 1px solid;
border-color: inherit;
opacity: 1;
left: 0;
.lib-rotate(0deg);
-webkit-transition: .25s transform ease-in-out;
-moz-transition: .25s transform ease-in-out;
-o-transition: .25s transform ease-in-out;
transition: .25s transform ease-in-out;
}
#nav-icon3 span:nth-child(1) {
top: 0px;
}
#nav-icon3 span:nth-child(2),#nav-icon3 span:nth-child(3) {
top: 8px;
}
#nav-icon3 span:nth-child(4) {
top: 16px;
}
.nav-open { #nav-icon3 span:nth-child(1) {
top: 8px;
width: 0%;
left: 50%;
}}
.nav-open { #nav-icon3 span:nth-child(2) {
.lib-rotate(45deg);
}}
.nav-open {
#nav-icon3 span:nth-child(3) {
.lib-rotate(-45deg);
}
}
.nav-open {
#nav-icon3 span:nth-child(4) {
top: 8px;
width: 0%;
left: 50%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment