-
-
Save Nesa344/4241ccf0bb8ae9728fde63ed4c224a86 to your computer and use it in GitHub Desktop.
3 Hamburger menu button click animations
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
/*== STEP 1 ==*//*Body Reset*/ | |
body { | |
margin: 0; | |
padding: 0; | |
font-family: Arial, Helvetica, sans-serif; | |
background: #333; | |
display: flex; | |
justify-content: space-evenly; | |
align-items: center; | |
min-height: 100vh; | |
} | |
/*== STEP 2 ==*//*Main Container & Checkbox*/ | |
.nav-btn { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
width: 4em; | |
height: 4em; | |
position: relative; | |
} | |
.nav-btn .btn { | |
-webkit-appearance: none; | |
outline: none; | |
cursor: pointer; | |
z-index: 2; | |
transition: 0.6s; | |
} | |
/*== STEP 3 ==*//*Styles When the Checkbox is checked*/ | |
.nav-btn .btn:checked ~ .lines .line:nth-child(1) { | |
opacity: 0; | |
} | |
.nav-btn .btn:checked ~ .lines .line:nth-child(3) { | |
transform: rotate(45deg) translate(-2em, 0.4em); | |
} | |
.nav-btn .btn:checked ~ .lines .line:nth-child(2) { | |
transform: rotate(-45deg) translate(-1.8em, -0.6em); | |
} | |
/*== STEP 4 ==*//*Hamburger Lines*/ | |
.nav-btn .btn, | |
.nav-btn .lines { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
width: 100%; | |
height: 100%; | |
} | |
/*== STEP 5 ==*//*Individual Line*/ | |
.nav-btn .line { | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
width: 90%; | |
height: 0.3em; | |
background: #fff; | |
pointer-events: none; | |
transition: 0.3s; | |
} | |
.nav-btn .line:nth-child(2) { top: 25%; } | |
.nav-btn .line:nth-child(3) { top: 75%; } | |
/*== STEP 6 ==*//*Additional v2 and v3 styles*/ | |
.navbtn-2 .btn:checked ~ .lines .line:nth-child(1) { | |
top: -1em; | |
} | |
.navbtn-3 .btn:checked ~ .lines .line:nth-child(1) { | |
transform: rotate(180deg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment