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.

Rothy's Brand Platform

9.12.22

Marco Cornacchia

9.8.22

Custom multi-select field in Webflow Form

9.7.22

Commercial Type

9.6.22

The Audacious Project

9.6.22

Finsweet Nobull

9.6.22

Aro

9.5.22

Creator Roadmap

$0+
9.4.22

Finsweet Attributes Ready JS Method

8.31.22

Attentive Holiday

8.30.22

Homerun Style System

8.30.22

Surfer

8.30.22

Effect All Siblings on Hover With CSS

8.30.22

Fable

8.29.22

Herman Mold + Tooling, Inc.

8.28.22

Framer

8.28.22

SystemFlow

8.28.22

Building a CMS Quiz in Webflow using WeBlocks

8.28.22

Top 3 tricks for CMS collection lists in Webflow

8.28.22

Creating Lottie Files Using Illustrator & After Effects for Webflow

8.28.22

Building a Liquid Nav in Webflow

8.28.22

Timothy Ricks JQuery Builder Course

8.28.22

Adaptive Page Loader in Webflow

8.28.22

Top 5 CSS Tricks You Must Know for Webflow

8.28.22

Using VS Code and GitHub with Webflow

8.28.22

The Webflow Masterclass - Learn how to build websites in Webflow

$695
8.28.22

Create Award Winning Animation and Interaction Design in Webflow

$110
8.28.22

JQuery Basics Tutorial for Webflow

8.28.22

Let your client add, remove, & rearrange page sections from the Webflow Editor

8.28.22

Improve UX Using Cookies in Webflow

8.28.22

Building a basic game in Webflow

8.28.22

Overlapping Page Transitions in Webflow

8.28.22

Using Airtable to power the data on your Webflow site

8.28.22

Stacker App + Airtable = Awesome Webflow Team Management

8.28.22

Top Five Interactions Designers Struggle to Create in Webflow

8.28.22

Using Matter.js in Webflow

8.28.22

How to Webflow like a boss

$100
8.28.22

Three Tips for Using Custom Code in Webflow

8.28.22

Will Editor X Replace Webflow?

8.28.22

Rowy

8.25.22

Dock

8.24.22

Pipedream

8.23.22

Accessibility Checklist

8.23.22

Ori Scanning

8.20.22

Life Extension Ventures

8.18.22

NODO x MAX

8.18.22

Word Counter

8.17.22

Displaay Type Foundry

8.16.22

LAZAREV

8.16.22

Modern Life

8.11.22

Framer Tips

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