Skip to content

Instantly share code, notes, and snippets.

@leogono
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leogono/f580d9790e96024db9b4 to your computer and use it in GitHub Desktop.
Save leogono/f580d9790e96024db9b4 to your computer and use it in GitHub Desktop.
interactive hamburger menu icon
<div class="interactive-menu-button">
<a href="#">
<span>Menu</span>
</a>
</div>

interactive hamburger menu icon

hamburger menu icon which transforms into X if it's active. Good to toggle menu.

A Pen by Leo Gono on CodePen.

License.

$('.interactive-menu-button a').click(function() {
$(this).toggleClass('active');
});
.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