.lock-scroll { overflow: hidden; } in the Head Code to prevent scrolling.</body> tag to toggle the lock-scroll class on menu click..menu-button-class with your menu button's class, publish, and test the changes.To lock and unlock the scrolling of the body when a burger menu is clicked in Webflow, you'll need to use some custom CSS and JavaScript interactions. Here’s how you can do it:
body.lock-scroll { overflow: hidden; }
document.addEventListener('DOMContentLoaded', function () {
var menuButton = document.querySelector('.menu-button-class'); // Replace with your menu button class
var body = document.body;
menuButton.addEventListener('click', function () {
if (body.classList.contains('lock-scroll')) {
body.classList.remove('lock-scroll'); // Unlock scrolling
} else {
body.classList.add('lock-scroll'); // Lock scrolling
}
});
});
.menu-button-class with the actual class name of your burger menu button.
To lock and unlock body scrolling with a burger menu click in Webflow, use a combination of custom CSS and JavaScript. Add a lock-scroll class to hide overflow and control this class with JavaScript based on menu interactions.