Skip to content

Instantly share code, notes, and snippets.

@digital-surgeon
Created October 12, 2015 09:20
Show Gist options
  • Select an option

  • Save digital-surgeon/30d38b30605af292f7af to your computer and use it in GitHub Desktop.

Select an option

Save digital-surgeon/30d38b30605af292f7af to your computer and use it in GitHub Desktop.
Burger menu toggle
<div id="toggle">
<input type="checkbox">
<span></span>
</div>
body {
background: #4183D7;
}
#toggle {
position: relative;
width: 30px;
height: 26px;
margin: 100px auto;
input {
position: absolute;
top: -3px;
left: -3px;
width: 100%;
height: 100%;
z-index: 1;
opacity: 0;
cursor: pointer;
&:checked {
+ span {
background: transparent;
&:after {
transform: rotate(45deg) translate(-1px, -8px);
}
&:before {
transform: rotate(-45deg) translate(-4px, 12px);
}
}
}
}
span {
position: absolute;
width: 100%;
height: 5px;
background: #fff;
margin-top: 10px;
&:before, &:after {
content: "";
position: absolute;
width: 100%;
height: 5px;
background: #fff;
top: -9px;
transition: 0.3s;
}
&:after {
top: 9px;
}
}
}
@ahmedam55

Copy link
Copy Markdown

Very simple and elegant solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment