Skip to content

Instantly share code, notes, and snippets.

@evdeveloper
Last active April 8, 2024 15:13
Show Gist options
  • Save evdeveloper/4385c8c3286622602aa33738dbcc379e to your computer and use it in GitHub Desktop.
Save evdeveloper/4385c8c3286622602aa33738dbcc379e to your computer and use it in GitHub Desktop.
Sandwich menu
.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