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

Affinity

11.2.25

Hugeicons Webflow App

10.31.25

Flint

10.31.25

Finsweet Extension Webflow App

10.31.25

Webflow Code Component Deploy

10.31.25

Context7

10.31.25

Good Friends Agency

10.29.25

Hubspot Webflow App

10.23.25

Brainfish

10.22.25

Superplan

10.22.25

Reve

10.22.25

Oratory

10.19.25

Brand Appart

10.17.25

Arc

10.15.25

Lando Norris

10.15.25

Claude

10.15.25

Amrit Palace

10.13.25

Arqui9

10.9.25

Fried Egg Golf

10.9.25

N4 Studio

10.9.25

Athlee

10.3.25

Weavy

10.3.25

Pulso Hotel

9.30.25

Codrops Creative Hub

9.30.25

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