hamburger menu icon which transforms into X if it's active. Good to toggle menu.
Last active
August 29, 2015 14:13
-
-
Save leogono/f580d9790e96024db9b4 to your computer and use it in GitHub Desktop.
interactive hamburger menu icon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="interactive-menu-button"> | |
<a href="#"> | |
<span>Menu</span> | |
</a> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.interactive-menu-button a').click(function() { | |
$(this).toggleClass('active'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.interactive-menu-button { | |
position: relative; | |
background: #f1c40f; | |
padding: 10px; | |
height: 40px; | |
a { | |
width: 20px; | |
height: 20px; | |
display: block; | |
position: relative; | |
span { | |
height: 2px; | |
position: absolute; | |
background: #000; | |
text-indent: -999em; | |
width: 100%; | |
top: 6px; | |
&:before, &:after { | |
content: ''; | |
height: 2px; | |
background: #000; | |
width: 100%; | |
position: absolute; | |
top: -6px; | |
left: 0; | |
transition: all 0.5s cubic-bezier(0, 0.275, 0.125, 1); | |
} | |
&:after { | |
top: 6px; | |
} | |
} | |
&.active span { | |
background: transparent; | |
&:before { | |
transform: translateY(6px) translateX(1px) rotate(45deg); | |
} | |
&:after { | |
transform: translateY(-6px) translateX(1px) rotate(-45deg); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment