Skip to content

Instantly share code, notes, and snippets.

@vincentntang
Last active September 17, 2018 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincentntang/dea2a10ffb95b8be3322e7053dc9caa2 to your computer and use it in GitHub Desktop.
Save vincentntang/dea2a10ffb95b8be3322e7053dc9caa2 to your computer and use it in GitHub Desktop.
Hamburger Menu CSS with Animation
#hamburger
.bar1
.bar2
.bar3
$(document).ready(function() {
$('#hamburger').on("click",function(){
$(this).toggleClass('open');
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
#hamburger {
display: inline-block;
cursor: pointer;
background-color: lightgrey;
transform: scale(10); /* For viewing purposes only, delete this in production*/
transform-origin: top left; /* For viewing purposes only, delete this in production*/
}
.bar1,
.bar2,
.bar3 {
width: 35px;
height: 5px;
background-color: grey;
margin-top: 6px;
margin-bottom: 6px;
transition: 0.4s;
border-radius: 7px;
}
.open {
.bar1{
transform: rotate(-45deg) translate(-9px,6px);
}
.bar2{
opacity: 0;
}
.bar3 {
transform: rotate(45deg) translate(-8px,-8px);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment