Skip to content

Instantly share code, notes, and snippets.

@Cathrin-Demyokhina
Created May 10, 2016 14:22
Show Gist options
  • Save Cathrin-Demyokhina/d3bf522b4ace45294a0e5271efaebb26 to your computer and use it in GitHub Desktop.
Save Cathrin-Demyokhina/d3bf522b4ace45294a0e5271efaebb26 to your computer and use it in GitHub Desktop.
<div class='sandwich'>
<div class='sw-topper'></div>
<div class='sw-bottom'></div>
<div class='sw-footer'></div>
</div>
.sandwich {
width: 35px;
height: 35px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.sw-topper {
position: relative;
top: 3px;
width: 35px;
height: 3px;
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: 35px;
height: 3px;
top: 13px;
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: 35px;
height: 3px;
top: 23px;
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(45deg);
}
.sandwich.active .sw-bottom {
top: 10px;
transform: rotate(-45deg);
}
.sandwich.active .sw-footer {
opacity: 0;
top: 0;
transform: rotate(180deg);
}
$(".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