<div class="nav-main-mobile">
<button class="mobile-navigation-button hamburger hamburger--squeeze" id="js-mobile-navigation-button" type="button">
<div class="hamburger-box">
<div class="hamburger-inner"></div>
</div>
<span class="hamburger-label js-hamburger-label" data-menu-text="Menu" data-close-text="Close">Menu</span>
</button>
</div>
<div class="nav-main-mobile">
<button class="mobile-navigation-button hamburger hamburger--squeeze" id="js-mobile-navigation-button" type="button">
<div class="hamburger-box">
<div class="hamburger-inner"></div>
</div>
<span class="hamburger-label js-hamburger-label" data-menu-text="Menu" data-close-text="Close">Menu</span>
</button>
</div>
{
"triggerFor": "inputId"
}
/*!
* Hamburgers
* @description Tasty CSS-animated hamburgers
* @author Jonathan Suh @jonsuh
* @site https://jonsuh.com/hamburgers
* @link https://github.com/jonsuh/hamburgers
*/
/***
*** Slider Reverse
***/
.hamburger--slider .hamburger-inner {
top: 2px;
}
.hamburger--slider .hamburger-inner::before {
top: 10px;
transition-property: transform, opacity;
transition-timing-function: ease;
transition-duration: 0.15s;
}
.hamburger--slider .hamburger-inner::after {
top: 20px;
}
.hamburger--slider.mobile-navigation-button--active .hamburger-inner {
transform: translate3d(0, 10px, 0) rotate(-45deg);
}
.hamburger--slider.mobile-navigation-button--active .hamburger-inner::before {
transform: rotate(45deg) translate3d(5.71429px, -6px, 0);
opacity: 0;
}
.hamburger--slider.mobile-navigation-button--active .hamburger-inner::after {
transform: translate3d(0, -20px, 0) rotate(90deg);
}
/*!
* Hamburgers
* @description Tasty CSS-animated hamburgers
* @author Jonathan Suh @jonsuh
* @site https://jonsuh.com/hamburgers
* @link https://github.com/jonsuh/hamburgers
*/
/*
* Spin
*/
.hamburger--spin .hamburger-inner {
transition-duration: 0.22s;
transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
.hamburger--spin .hamburger-inner::before {
transition: top 0.1s 0.25s ease-in, opacity 0.1s ease-in;
}
.hamburger--spin .hamburger-inner::after {
transition: bottom 0.1s 0.25s ease-in,
transform 0.22s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
.hamburger--spin.mobile-navigation-button--active .hamburger-inner {
transform: rotate(225deg);
transition-delay: 0.12s;
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
.hamburger--spin.mobile-navigation-button--active .hamburger-inner::before {
top: 0;
opacity: 0;
transition: top 0.1s ease-out, opacity 0.1s 0.12s ease-out;
}
.hamburger--spin.mobile-navigation-button--active .hamburger-inner::after {
bottom: 0;
transform: rotate(-90deg);
transition: bottom 0.1s ease-out,
transform 0.22s 0.12s cubic-bezier(0.215, 0.61, 0.355, 1);
}
/*!
* Hamburgers
* @description Tasty CSS-animated hamburgers
* @author Jonathan Suh @jonsuh
* @site https://jonsuh.com/hamburgers
* @link https://github.com/jonsuh/hamburgers
*/
/*
* Squeeze
*/
.hamburger--squeeze .hamburger-inner {
transition-duration: 0.075s;
transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
.hamburger--squeeze .hamburger-inner::before {
transition: top 0.075s 0.12s ease, opacity 0.075s ease;
}
.hamburger--squeeze .hamburger-inner::after {
transition: bottom 0.075s 0.12s ease,
transform 0.075s cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
.hamburger--squeeze.mobile-navigation-button--active .hamburger-inner {
transform: rotate(45deg);
transition-delay: 0.12s;
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
.hamburger--squeeze.mobile-navigation-button--active .hamburger-inner::before {
top: 0;
opacity: 0;
transition: top 0.075s ease, opacity 0.075s 0.12s ease;
}
.hamburger--squeeze.mobile-navigation-button--active .hamburger-inner::after {
bottom: 0;
transform: rotate(-90deg);
transition: bottom 0.075s ease,
transform 0.075s 0.12s cubic-bezier(0.215, 0.61, 0.355, 1);
}
:root {
--nav-trigger-burger-width: 30px;
--nav-trigger-burger-height: 20px;
--nav-trigger-burger-stroke-width: 3px;
--nav-trigger-color: var(--color-black, #fff);
--nav-trigger-border-color: var(--color-secondary);
--nav-trigger-border-opacity: 25%;
}
.nav-main-mobile {
display: flex;
margin-right: -15px;
border-left: 1px solid color-mod(var(--nav-trigger-border-color, white) alpha(var(--nav-trigger-border-opacity, 25%)));
@media (--viewport-sm-min) {
display: none;
}
}
.mobile-navigation-open {
overflow: hidden;
position: fixed;
width: 100%;
.topbar__navigation {
transform: translateX(0);
opacity: 1;
&__item {
display: block;
}
}
}
.mobile-navigation-button {
border: none;
outline: none;
background-color: transparent;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 80px;
height: 100%;
transform: translateX(0);
opacity: 1;
transition: all 0.3s var(--easeInOutQuart);
user-select: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
&__text {
color: var(--color-primary);
text-align: center;
font-size: 10px;
}
}
.hamburger {
padding: 15px 15px;
cursor: pointer;
transition-property: opacity, filter;
transition-duration: 0.15s;
transition-timing-function: linear;
font: inherit;
color: inherit;
text-transform: none;
background-color: transparent;
border: 0;
margin: 0;
overflow: visible;
outline: none;
background-color: transparent;
width: 80px;
user-select: none;
}
.hamburger-label {
font-size: 14px;
margin-top: 3px;
transition: all 0.3s var(--easeInOutQuart);
font-weight: bold;
}
.hamburger-box {
width: 30px;
height: 24px;
display: inline-block;
position: relative;
}
.hamburger-inner {
display: block;
top: 50%;
margin-top: -2px;
}
.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
width: 30px;
height: 3px;
background-color: var(--color-primary);
position: absolute;
transition-property: transform;
transition-duration: 0.15s;
transition-timing-function: ease;
}
.hamburger-inner::before,
.hamburger-inner::after {
content: '';
display: block;
}
.hamburger-inner::before {
top: -9px;
}
.hamburger-inner::after {
bottom: -9px;
}
const navButton = document.querySelector('#js-mobile-navigation-button');
const body = document.querySelector('#site');
const hamburgerLabel = document.querySelector('.js-hamburger-label');
if (navButton) {
const menuText = hamburgerLabel.getAttribute('data-menu-text');
const closeText = hamburgerLabel.getAttribute('data-close-text');
// Open mobile navigation
navButton.addEventListener(
'click',
function () {
body.classList.toggle('mobile-navigation-open');
this.classList.toggle('mobile-navigation-button--active');
if (hamburgerLabel.parentNode.classList.contains('mobile-navigation-button--active')) {
hamburgerLabel.innerHTML = closeText;
} else {
hamburgerLabel.innerHTML = menuText;
}
},
true,
);
}
Require an animation from https://github.com/jonsuh/hamburgers/blob/master/dist/hamburgers.css to work
Change this class “hamburger–spin” to use another style