Skip to content

Instantly share code, notes, and snippets.

@irunatbullets
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save irunatbullets/79feb0cd78cc774baca9 to your computer and use it in GitHub Desktop.

Select an option

Save irunatbullets/79feb0cd78cc774baca9 to your computer and use it in GitHub Desktop.
Google Material Hamburger Button
<div class="hamburger">
<div></div>
<div></div>
<div></div>
</div>
$(function(){
var activateHamburger = function(event) {
var el = $(this);
if (el.hasClass('active')){
el.addClass('active-end');
el.one('transitionend', function(){
el.removeClass('active active-end')
});
} else {
el.addClass('active');
}
};
$('.hamburger').click(activateHamburger);
});
@import "compass/css3";
*,
*:before,
*:after {
@include box-sizing(border-box);
}
%clearfix {
&:before,
&:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
@include has-layout;
}
.hamburger {
cursor: pointer;
width: 30px;
height: 30px;
padding: 3px;
margin: 20px;
@extend %clearfix;
& > div {
background: #03A9F4;
height: 4px;
margin-bottom: 4px;
float: left;
width: 100%;
}
& > div:nth-child(1),
& > div:nth-child(3) {
float: right;
}
&.active {
@include transition(all 0.6s ease);
@include simple-transform(1, 180deg, 0, 4px);
& > div {
@include transition(all 0.6s ease);
}
& > div:nth-child(1),
& > div:nth-child(3) {
width: 70%;
}
& > div:nth-child(2) {
width: 90%;
}
& > div:nth-child(1) {
@include simple-transform(1, 45deg, 2px, 2px);
}
& > div:nth-child(3) {
@include simple-transform(1, -45deg, 2px, -2px);
}
&.active-end {
@include simple-transform(1, 360deg, 0, 0);
& > div {
width: 100%;
}
& > div:nth-child(1) {
@include simple-transform(1, 0deg, 0, 0);
}
& > div:nth-child(3) {
@include simple-transform(1, 0deg, 0, 0);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment