Last active
April 8, 2024 15:13
-
-
Save evdeveloper/4385c8c3286622602aa33738dbcc379e to your computer and use it in GitHub Desktop.
Sandwich menu
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
.sandwich | |
.sandwich__line.sandwich__line--top | |
.sandwich__line.sandwich__line--middle | |
.sandwich__line.sandwich__line--bottom | |
.sandwich { | |
$this: &; | |
display: none; | |
position: relative; | |
width: 32px; | |
height: 20px; | |
cursor: pointer; | |
&--active { | |
#{$this}__line { | |
&--top { | |
top: 10px; | |
transform: rotate(45deg); | |
} | |
&--middle { opacity: 0; } | |
&--bottom { | |
top: 10px; | |
transform: rotate(-45deg); | |
} | |
} | |
} | |
&__line { | |
display: block; | |
width: 100%; | |
height: 2px; | |
position: absolute; | |
background-color: var(--white); | |
left: 0; | |
transition: all var(--duration); | |
&--top { top: 0; } | |
&--middle { top: 9px; } | |
&--bottom { top: 18px; } | |
} | |
} | |
var clickMenu = $('.sandwich'); | |
var sandwich = function () { | |
$(document).on('click', '.sandwich', function(e) { | |
e.preventDefault(); | |
$(this).toggleClass('sandwich--active'); | |
clickMenu.toggleClass('active'); | |
}); | |
}; | |
sandwich(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment