Skip to content

Instantly share code, notes, and snippets.

@konratnox
Created October 30, 2017 10:01
Show Gist options
  • Save konratnox/422ed6782942b69439696e58532ac6e9 to your computer and use it in GitHub Desktop.
Save konratnox/422ed6782942b69439696e58532ac6e9 to your computer and use it in GitHub Desktop.
<div id="mobile-menu-button" class="mobile-menu-button">
<span></span>
<span></span>
<span></span>
</div>
$('#mobile-menu-button').click(function() {
$(this).toggleClass('active');
});
.mobile-menu-button {
display: block;
color: $color-green;
position: relative;
span {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transition: 250ms ease-in-out;
display: block;
opacity: 1;
width: 30px;
height: 3px;
background-color: $color-green;
}
span:nth-of-type(1) {
margin: -9px 0 0;
}
span:nth-of-type(3) {
margin: 9px 0 0;
}
&.active span:nth-of-type(1) {
transform: translate(-50%, -50%) rotate(45deg);
margin: 0;
}
&.active span:nth-of-type(2) {
opacity: 0;
}
&.active span:nth-of-type(3) {
transform: translate(-50%, -50%) rotate(-45deg);
margin: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment