A Pen by Nariman Adam on CodePen.
Created
October 12, 2015 09:20
-
-
Save digital-surgeon/30d38b30605af292f7af to your computer and use it in GitHub Desktop.
Burger menu toggle
This file contains hidden or 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 id="toggle"> | |
| <input type="checkbox"> | |
| <span></span> | |
| </div> |
This file contains hidden or 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
| 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; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very simple and elegant solution!