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.

Get hired at Prevent Body Scroll on Click

We've partnered with startups.gallery to help you find new opportunities at the leading startups in design, development, and AI.

Industries

Creators

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

Curated: 
2.11.22

Similar items

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

Webflow custom code snippets you would use. Episode 1

12.3.19

Parabola and Webflow: Automatically feature your most popular blog post

12.3.19

Infinite scroll: how to keep your audience engaged in 2019

12.3.19

Let's Redesign Web Design

12.3.19

How To Create Dynamic Form Content

12.3.19

Follow up on searchIQ that enables google-like features on webflow

12.3.19

Google Sheets to Webflow w/ Zapier

12.3.19

Creating a Notification bar in Webflow

12.3.19

Full Multi Language Site

12.3.19

How to include current URL in a form

12.3.19

How to get interactions working with fullPage JS

12.3.19

Webflow Secrets

12.3.19

11 time-saving pro tips for web designers working in Webflow

12.3.19

Control Webflow native slider with arrow keys

12.3.19

Using List JS with Webflow

12.3.19

Embracing Webflow as a Frontend Developer

12.3.19

Dynamic Forms With Webflow

12.3.19

How to add dynamic filtering and sorting to your Webflow websites

12.3.19

Webflow Pages WordPress Plugin

12.3.19

Stop handing off concepts and start designing real products with Webflow.

12.3.19

Product Prototyping with Webflow

12.3.19

Adding cookies to custom modals

12.3.19

Webflow Seamless Pagination

12.3.19

The Low-Code/No-Code Movement: More Disruptive Than You Realize

12.3.19

CSS Scroll Snap

11.21.19

CSS Aspect-Ratio

11.21.19

Min/Max/Clamp Individual Styles

11.21.19

CSS Combinators

11.21.19

@Media Prefers Dark/Light

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.