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

Workway

12.10.25

Made Light Wheels

12.10.25

CSS Wrapped 2025

12.10.25

Frequency Breathwork

12.10.25

Gradient Labs

12.8.25

Weaverbird

12.8.25

Trust Keith

12.8.25

N47

12.2.25

Paris by Emily

12.2.25

Interactive SVG Animations

12.1.25

OneTech

12.1.25

<divs> Webflow AI Generator

11.22.25

Pablo

11.22.25

Raydian

11.22.25

Paper Tiger

11.21.25

Making UX Decisions

11.15.25

Efecto

11.15.25

Konpo Studio

11.14.25

Tesoro

11.14.25

Kudanil Explorer

11.11.25

React Email

11.11.25

Let's Do This

11.11.25

Osmo

€25/mo
11.11.25

Claimable

11.4.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