Created
August 29, 2020 17:29
-
-
Save wpflames/b3713e440a47122034c90be5bd798ae0 to your computer and use it in GitHub Desktop.
Hamburger Menu Toggle Animation 3 - SCSS
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
| *{ | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| font-family: 'Poppins', sans-serif; | |
| } | |
| body{ | |
| background: black; | |
| } | |
| #toggle{ | |
| position: absolute; | |
| top: 20px; | |
| left: 20px; | |
| padding: 10px; | |
| transition: .5s; | |
| cursor: pointer; | |
| display: block; | |
| width: 60px; | |
| height: 60px; | |
| z-index: 2; | |
| span{ | |
| position: absolute; | |
| transform: translate(-50%, -50%); | |
| top: 50%; | |
| left: 50%; | |
| width: 40px; | |
| height: 4px; | |
| background: white; | |
| border-radius: 4px; | |
| display: block; | |
| transition: .5s; | |
| &:nth-child(1){ | |
| transform: translate(-50%, -50%) translateY(-14px); | |
| transition: .8s; | |
| } | |
| &:nth-child(4){ | |
| transform: translate(-50%, -50%) translateY(14px); | |
| transition: .8s; | |
| } | |
| } | |
| &.active{ | |
| width: 55px; | |
| transition: .5s; | |
| span{ | |
| &:nth-child(1){ | |
| transform: translate(-50%, -50%) translateY(-35px); | |
| opacity: 0; | |
| } | |
| &:nth-child(4){ | |
| transform: translate(-50%, -50%) translateY(35px); | |
| opacity: 0; | |
| } | |
| &:nth-child(2){ | |
| transform: translate(-50%, -50%) rotate(45deg); | |
| } | |
| &:nth-child(3){ | |
| transform: translate(-50%, -50%) rotate(-45deg); | |
| } | |
| } | |
| } | |
| } | |
| #menu.active{ | |
| left: 0; | |
| } | |
| #menu{ | |
| background: tomato; | |
| position: absolute; | |
| left: -100%; | |
| height: 100vh; | |
| width: 300px; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| flex-direction: column; | |
| margin: 0; | |
| transition: .4s; | |
| z-index: 1; | |
| li{ | |
| list-style: none; | |
| font-size: 2rem; | |
| line-height: 2; | |
| a{ | |
| text-decoration: none; | |
| font-weight: bold; | |
| color: white; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment