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.

Emperor OAR 2022

2.24.23

Guide on Migrating Your Wordpress Site to Webflow

2.23.23

Capital Template

2.22.23

Old Friend

2.22.23

HEX INC

2.22.23

How to Build Simple Chrome Extensions w/ Keegan Leary

2.21.23

How to create consistency in your website

2.20.23

Devolfs

2.20.23

Planet Lizard

2.20.23

Bento

2.20.23

htmx

2.20.23

bunny.net

2.20.23

UNFINISHED

2.20.23

JUST - 1-click payment solution

2.20.23

Webflow Examples Github Repo

2.20.23

Inclusive Components

2.20.23

Roman Tesliuk

2.20.23

Magic Rename

2.19.23

Kickstart Studio

2.19.23

Studio Gruhl

2.19.23

Relocate Element While Scrolling in Webflow

2.19.23

Mural

2.15.23

ThreeSixtyEight

2.15.23

Srbija Sans Font

2.15.23

CHRLS.DSGN

2.15.23

Das Glashaus In der Uckermark

2.15.23

Axis Arbor

2.15.23

BLZT Fonts Pack

2.14.23

Arillatype.Studio®

2.14.23

IEX Exchange

2.14.23

Notion API – Full Course for Beginners

2.14.23

Perspective

2.14.23

Cinch PR

2.14.23

Builder.io

2.14.23

Archetype

2.13.23

Jitter

2.11.23

WhistlePig

2.10.23

Splash

2.10.23

Filip Wróblewski

2.10.23

Webflow Autoplay Tabs w/ Play/Pause Button

2.9.23

Timothy Maurer

2.9.23

HvD Fonts

2.9.23

Universe

2.9.23

Chart.js

2.9.23

Superchart

2.9.23

Framepad

2.9.23

Genius by Diagram

2.9.23

Luxon

2.8.23

Add International Times with Timezones to your website

2.8.23

Hookdeck

2.8.23

Good Design Tools

2.8.23

Recreating an Award-Winning Game in Webflow

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