A Pen by Murray Nuttall on CodePen.
Last active
August 29, 2015 14:03
-
-
Save irunatbullets/79feb0cd78cc774baca9 to your computer and use it in GitHub Desktop.
Google Material Hamburger Button
This file contains hidden or 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="hamburger"> | |
| <div></div> | |
| <div></div> | |
| <div></div> | |
| </div> |
This file contains hidden or 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
| $(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); | |
| }); |
This file contains hidden or 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
| @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