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.
Tags
Industries
Creators
Share this item
Have feedback or a question related to this item? Drop us some feedback!
Subscribe for updates
Get updates on the latest curated resources and be the first to hear of new features.
One more step!
Check your email for a confirmation to ensure we got it right.
Creative portfolios, auth tools, and a URL code trick.
We hope you are having a stellar week! Here are this weeks featured inspiration, code and resources.