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.

Industries

Creators

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

Curated: 
2.11.22

Similar items

Advertise with No-Code Supply Co.

View item
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Lottieflow

12.3.19

Nocode.tech

12.3.19

Flowbase

12.3.19

Lobe

12.3.19

Adalo

12.3.19

Storychief

12.3.19

Foxy.io

12.3.19

Typeform

12.3.19

Uploadcare

12.3.19

Udesly

12.3.19

Xano

12.3.19

UI Bakery

12.3.19

@Media Prefers Dark/Light

11.21.19

CSS Combinators

11.21.19

Min/Max/Clamp Individual Styles

11.21.19

CSS Aspect-Ratio

11.21.19

CSS Scroll Snap

11.21.19
Load more

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.