.w--open
combo class to detect when it’s active.body.style.overflow = 'hidden'
when the menu is open, and add CSS for .nav-menu.w--open
with overscroll-behavior: contain
and touch-action: none
to block iOS background scroll.You're trying to create a fixed mobile menu in Webflow that prevents page scrolling behind the menu when it's open. However, disabling scroll via Webflow’s settings isn’t fully preventing background page scroll, especially on mobile devices. Here's how to resolve that properly.
w--open
or a custom combo class to the nav..nav-menu.w--open
) to apply additional styles or functionality.<body>
using Webflow interactions or custom code.<body>
to apply overflow: hidden when menu is open.Steps:
<script> const trigger = document.querySelector('.navbar-button-class'); // Your menu button const body = document.body; trigger.addEventListener('click', () => { const menuOpen = document.querySelector('.nav-menu-class').classList.contains('w--open'); if (menuOpen) { body.style.overflow = 'hidden'; } else { body.style.overflow = ''; } });</script>
Replace .navbar-button-class
and .nav-menu-class
with your actual class names.
Example:
<head>
):<style> .nav-menu.w--open { overscroll-behavior: contain; touch-action: none; }</style>
This helps block scroll chaining and touch gestures inside the menu area.
To create a fixed mobile menu without background scroll, set the navbar to fixed fullscreen, disable <body>
scrolling via script or interaction when the menu opens, and manage iOS-specific behavior with overscroll-behavior
and touch-action
. Webflow’s default settings alone often aren’t enough.