Created
September 9, 2014 15:32
-
-
Save michaeltcoelho/ce72230bf7e34f44f37f to your computer and use it in GitHub Desktop.
A Pen by Michael.
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="menu-icon"> | |
<span></span> | |
</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
var button = document.querySelector('.menu-icon'); | |
button.addEventListener('click', function (){ | |
button.classList.toggle('open'); | |
}); |
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
/* | |
menu icon css3 | |
*/ | |
.menu-icon { | |
position: relative; | |
display: block; | |
width: 4em; | |
height: 4em; | |
cursor: pointer; | |
/* to center */ | |
margin: 0 auto; | |
float: none; | |
-webkit-transition: all 0.3s; | |
transition: all 0.3s; | |
} | |
.menu-icon > span { | |
position: absolute; | |
top: 50%; | |
display: block; | |
width: 100%; | |
height: 0.5em; | |
margin-top: -0.5em; | |
background-color: #e74c3c; | |
} | |
.menu-icon > span:before, | |
.menu-icon > span:after { | |
content: ""; | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
background-color: #e74c3c; | |
-webkit-transition: all 0.3s; | |
transition: all 0.3s; | |
} | |
.menu-icon > span:before { | |
-webkit-transform: translateY(-1em); | |
transform: translateY(-1em); | |
} | |
.menu-icon > span:after { | |
-webkit-transform: translateY(1em); | |
transform: translateY(1em); | |
} | |
/* OPENED */ | |
.menu-icon.open { | |
-webkit-transform: rotate(45deg); | |
transform: rotate(45deg); | |
} | |
.menu-icon.open > span:before { | |
-webkit-transform: rotate(90deg); | |
transform: rotate(90deg); | |
} | |
.menu-icon.open > span:after { | |
-webkit-transform: rotate(90deg); | |
transform: rotate(90deg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment