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.

ECAL Typefaces

2.3.23

Figma to Webflow Plugin

2.2.23

Text Connector DateTime Formats

2.2.23

Quilt

2.2.23

Optimal Controls AI

2.2.23

100 Days Of More Or Less Modern CSS

2.2.23

Memo

2.2.23

Notion Second Brain

$99
2.1.23

Whiteboard's Agency Report

2.1.23

Nucleo

$99
1.31.23

Payhip

1.31.23

Cloudpress

1.30.23

Nube

1.30.23

Automatisch

1.30.23

Deduxer Studio

1.30.23

Vev

1.28.23

Animate Along SVG Path Using GSAP

1.27.23

Clean Shot X

1.27.23

Reverse Proxy for Webflow Pt.1

1.27.23

NoCode Exits

1.26.23

August

1.26.23

Thomas Bosc

1.26.23

Versoly

1.26.23

Images Inside Text Spans in Webflow

1.26.23

Ghostwrite

1.25.23

Xnapper

1.25.23

Simple Type Co.

1.25.23

Using Webflow with Cloudflare

1.24.23

Buildcamp

1.23.23

100 Days of No-Code

1.23.23

Sammy

1.23.23

Remix Framer

1.22.23

Persistent Dark Mode Switch

1.22.23

Scrollyvideo.js

1.22.23

Iconic

$99/yr
1.22.23

Vintage Voyage Design Supply

1.22.23

Supa Palette

1.22.23

fffuel

1.22.23

Framer.supply

1.21.23

Softr

1.21.23

Nocode.gallery

1.21.23

LanceID

1.21.23

Bubble Bootcamp

$249
1.21.23

Understanding IF and SWITCH Statements in Airtable

1.20.23

Flow Party

1.20.23

Søren Rose Studio

1.20.23

How to add a custom class to an element in Framer

1.20.23

Streamline Icons

$29/mo
1.20.23

Healthy Together

1.20.23

Natroceutics

1.20.23

Import Colors From Figma to Webflow

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