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.

Show/Hide Based on Date/Time

3.27.20

Click to Copy to Clipboard

3.25.20

Social Share Links + Open Graph Meta Data

3.19.20

7 Things to Know About Webflow

3.19.20

Gemnote

3.11.20

Appcues

3.11.20

Back to Previous Page Button

3.11.20

Vovi

2.29.20

YCode

2.28.20

Me | Today

2.28.20

Rapper Radio

2.28.20

Dwellito

2.28.20

Bravo Studio App

2.28.20

Webflow Lightbox Custom Overlay Color

2.28.20

Unqork

2.27.20

Custom Scrollbar

2.27.20

Petal

2.25.20

Autocode

2.21.20

Stacker

2.21.20

Print a Specific Element w/ Button

2.21.20

Mobile Tabs to Dropdown

2.16.20

Patra Capital

2.12.20

Jomor Design

2.5.20

Text Bottom Border Animation on Hover

2.5.20

Play

2.4.20

Paragon

2.4.20

Set Text to Today's Date

2.3.20

Klokki

1.30.20

Pest Stop Boys

1.30.20

Unicorn Factory

1.29.20

Cottage Grove Church

1.29.20

Unite America

1.29.20

EZ GIF

1.25.20

Userbase

1.25.20

AppSheet

1.25.20

Betty Blocks

1.25.20

Obviously Ai

1.23.20

Tadabase

1.22.20

Rows

1.22.20

Wappler

1.22.20

Hide Static Element if Webflow CMS Collection is Empty

1.19.20

Building an online school in Webflow

1.14.20

TSE Culture Manual

1.13.20

Dockyard Social

1.10.20

Aesthetica

1.10.20

Page Change Click Delay

1.6.20

Click This to Click That

1.6.20

Hide/Show Element From <select>

1.6.20

Thunkable

12.29.19

The Finish Line Is Never The End

12.23.19

Bildr

12.22.19

No Code is New Programming

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