Prevent Body Scroll on Click

Prevent Body Scroll on Click

When clicking something lock the scroll of <body> if it isn’t already locked (set to overflow: hidden;). This is useful for things like opening modals, a mobile nav, etc. to ensure the user doesn’t have two levels of scrolling occurring at once.

Update the classes of .nav-button and .nav-overlay in the snippet below with the class you use on the mobile menu button and an overlay div that covers the rest of the screen if needed when the mobile menu is open. If you don’t have a separate overlay div, you can also target the native one that is part of the native Nav element in Webflow, which has the class of .w-nav-overlay.

Have feedback or a question related to this item? Drop us some feedback!

Curated: 
2.11.22

Similar items

Items
2771
Search

Instatic

7.3.26

The Content Architecture

6.19.26

BaseHub

6.19.26

Neue Academy™

6.19.26

fable-mode

6.19.26

Arcway

6.19.26

Opacity

6.19.26

Index.how

6.19.26

Paxel

6.19.26

Supaste

6.5.26

Cantor8

6.5.26

Simon Holm Studio

6.5.26

Ponder

5.30.26

AI in Design Report 2026

5.30.26

here.now

5.30.26

Scratch

5.30.26

Haven Foods

5.30.26

Index_Georgia

5.30.26

Storesynk

5.25.26

htmlbin

5.19.26

MONOLOG

5.19.26

Interfaces › Design Engineering Magazine

5.19.26

Ploy

5.19.26

Interfere

5.19.26

Bummer, no results

Try a different search/filter combo, or drop us some feedback if there is something missing you would love to see!

Reset filters

Subscribe for updates

Get updates on the latest curated resources and be the first to hear of new features.

Subscribe