Explore Bato Web Agency Webflow Certified Partner Profile Explore Bato Web Agency Webflow Certified Partner Profile

Why does a mobile page scroll behind an open menu or dialog?

Illustration without a description Illustration without a description

A mobile page scrolls behind an open menu when the overlay changes what is visible but leaves the document as the active scroll container. A high z-index does not disable scrolling. The open state must make the background inert and lock its scroll while the panel handles its own overflow.

 

Apply one class to the root or body when the menu opens, then remove it on every close path. overflow: hidden is a useful first choice. Some mobile layouts need a fixed-body lock that stores the current scroll position, because the document can otherwise move under a full-screen overlay.

 

The menu or dialog needs a bounded height and its own overflow rule when its content is long. Use a dynamic or small viewport unit with safe-area padding, then allow overflow-y auto on the panel. Overscroll containment can reduce scroll chaining when the panel reaches its top or bottom.

 

.overlay-panel {
position: fixed;
inset: 0;
max-height: 100dvh;
overflow-y: auto;
overscroll-behavior: contain;
padding-bottom: env(safe-area-inset-bottom, 0px);
}

html.overlay-open {
overflow: hidden;
}

 

Make background controls inert while the overlay is active and move focus into the dialog or menu. Restore focus to the trigger on close. A visual overlay without focus management lets keyboard and assistive-technology users operate the page beneath it even when touch scrolling appears locked.

 

Test with content shorter and longer than the screen, then open the panel after scrolling deep into the page. Drag at both panel boundaries and close through the button, Escape, overlay and navigation. The page should stay at the saved position, the panel must remain scrollable, and repeated cycles must not accumulate event listeners.