Last active
July 24, 2016 04:22
-
-
Save encody/403ce331183ad4d00795ee985228639f to your computer and use it in GitHub Desktop.
Transforming Hamburger Menu
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
/* | |
Video Guide: https://youtu.be/eqhEq9_uVas | |
*/ | |
var menus = document.getElementsByClassName('hamburger-menu'); | |
[].forEach.call(menus, function (m) { | |
m.addEventListener('click', function () { | |
m.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
/* | |
Video Guide: https://youtu.be/eqhEq9_uVas | |
*/ | |
body { | |
background-color: black; | |
padding: 1em; | |
font-size: 100px; | |
} | |
.hamburger-menu { | |
width: 1em; | |
height: 1em; | |
padding: 0.2em; | |
background-color: #0af; | |
cursor: pointer; | |
margin: 0 auto; | |
div { | |
background-color: white; | |
width: 1em; | |
height: 0.2em; | |
margin-bottom: 0.2em; | |
transition: all 0.2s ease-out; | |
} | |
&.open { | |
.one { | |
transform: translateY(0.4em) rotate(45deg); | |
} | |
.two { | |
opacity: 0; | |
} | |
.three { | |
transform: translateY(-0.4em) rotate(-45deg); | |
} | |
} | |
} |
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
<!-- | |
Video Guide: https://youtu.be/eqhEq9_uVas | |
--> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Hamburger Menu</title> | |
<link rel="stylesheet" href="hamburger.css"> | |
</head> | |
<body> | |
<div class="hamburger-menu"> | |
<div class="one"></div> | |
<div class="two"></div> | |
<div class="three"></div> | |
</div> | |
<script src="hamburger.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment