Skip to content

Instantly share code, notes, and snippets.

@alex-boom
Created December 8, 2016 12:22
Show Gist options
  • Save alex-boom/db286e0d70fc3483cd6e7e7594985ab9 to your computer and use it in GitHub Desktop.
Save alex-boom/db286e0d70fc3483cd6e7e7594985ab9 to your computer and use it in GitHub Desktop.
toggle-mnu
//toggle-mnu
html:
<div class="toggle-mnu" onclick="myFunction(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
<script>
function myFunction(x) {
x.classList.toggle("change");
}
</script>
css:
.toggle-mnu {
position: absolute;
top: 24px;
right: 20px;
display: inline-block;
cursor: pointer;
opacity: .6;
}
.bar1,
.bar2,
.bar3 {
width: 44px;
height: 5px;
background-color: white;
margin: 7px 0;
transition: 0.4s;
}
.change {
.bar1 {
transform: rotate(-45deg) translate(-9px, 7px);
}
.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