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.

Tom Parkes

3.12.24

Creators Guild of America

3.12.24

Flatpickr

3.12.24

Baseborn

3.12.24

Juice

3.11.24

Mollie

3.11.24

Axon Evidence

3.10.24

Teachable

3.10.24

SaaS Website Kit

3.10.24

Unspace

3.10.24

404s

3.7.24

Lattice State of People Strategy Report 2024

3.7.24

EmergentX

3.6.24

Zylon

3.5.24

Cortex

3.5.24

Anchor

3.5.24

Attiq R.

3.4.24

Inputflow Webflow App

3.2.24

Josiah Z

3.1.24

J. Sherwood

2.29.24

Wegrow

2.29.24

Echo

2.29.24

Rolodex Design

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

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

Pivot

2.23.24

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

Keystroke Pro

2.21.24

EverArt

2.21.24

Art Department Club

2.21.24

Macu Studio

2.19.24

Accessibility Maturity Model

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