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.

Josiah Z

3.1.24

J. Sherwood

2.29.24

Wegrow

2.29.24

Echo

2.29.24

Rolodex Design

2.29.24

M&C Saatchi Abel

2.29.24

Grant

2.29.24

AniMattor

2.29.24

xAttribute Webflow App

2.28.24

Futureneers

2.28.24

Other Land

2.28.24

DomoAI

2.28.24

Brutal Web

2.28.24

How to make text responsive with clamp

2.27.24

Goo Motion Library

2.27.24

Auditional

2.27.24

Fest Auto

2.27.24

Iambic Therapeutics

2.27.24

Joseph Berry

2.27.24

Cheerypick

2.26.24

Ostro

2.26.24

Figma to Replit Plugin

2.26.24

Migratify

2.26.24

Mast

3.13.23

Whalesync

1.8.23

Pivot

2.23.24

Jetboost

12.3.19

Highspire Learning

2.22.24

Kraftful

2.22.24

Avo

2.22.24

LanguageGUI

2.22.24

Example Webflow CSS Custom Properties

2.22.24

Quillow

2.22.24

Which Webflow framework should I use for my project?

2.22.24

Fathom Analytics

12.1.22

Keystroke Pro

2.21.24

EverArt

2.21.24

Art Department Club

2.21.24

Audienceful

8.1.22

Macu Studio

2.19.24

Accessibility Maturity Model

2.19.24

Redchurch

2.19.24

Lavender

2.19.24

Tomorro

2.19.24

Ben

2.19.24

Airtable vs Asana for project management: a guide for nerds

2.19.24

Huemint

2.19.24

Memberstack

12.3.19

Slater

6.2.23

House on a Hill

2.15.24

Figmatica

2.15.24

Unsection

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

Subscribe