Last active
November 22, 2017 09:41
-
-
Save AllThingsSmitty/6160d1f2a91509700053 to your computer and use it in GitHub Desktop.
Hamburger menu "open/close" icon
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
body { | |
height: 100%; | |
background: #262626; | |
} | |
.hamburger { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
margin: auto; | |
width: 60px; | |
height: 45px; | |
cursor: pointer; | |
-webkit-transition: .5s ease-in-out; | |
transition: .5s ease-in-out; | |
-webkit-transform: rotate(0); | |
-ms-transform: rotate(0); | |
transform: rotate(0); | |
} | |
.hamburger span { | |
position: absolute; | |
left: 0; | |
display: block; | |
width: 100%; | |
height: 9px; | |
border-radius: 9px; | |
background: #fff; | |
opacity: 1; | |
-webkit-transition: .25s ease-in-out; | |
transition: .25s ease-in-out; | |
-webkit-transform: rotate(0); | |
-ms-transform: rotate(0); | |
transform: rotate(0); | |
} | |
.hamburger span:nth-child(1) { top: 0; } | |
.hamburger span:nth-child(2), .hamburger span:nth-child(3) { top: 18px; } | |
.hamburger span:nth-child(4) { top: 36px; } | |
.hamburger.open span:nth-child(1) { | |
top: 18px; | |
left: 50%; | |
width: 0%; | |
} | |
.hamburger.open span:nth-child(2) { | |
-webkit-transform: rotate(45deg); | |
-ms-transform: rotate(45deg); | |
transform: rotate(45deg); | |
} | |
.hamburger.open span:nth-child(3) { | |
-webkit-transform: rotate(-45deg); | |
-ms-transform: rotate(-45deg); | |
transform: rotate(-45deg); | |
} | |
.hamburger.open span:nth-child(4) { | |
top: 18px; | |
left: 50%; | |
width: 0; | |
} |
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"> | |
<span></span> | |
<span></span> | |
<span></span> | |
<span></span> | |
</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
$(document).ready(function(){ | |
$(".hamburger").click(function(){ | |
$(this).toggleClass("open"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment