Stop russian invasion of Ukraine 🇺🇦

Preventing scroll when a pop-up is opened

Preventing scroll when a pop-up is opened

By default, when you open a pop-up or menu and start scrolling, the main content will scroll too. You can’t fix that with native Webflow features, but it’s not a big deal to add a short script to prevent this:

// Prevent scrolling on click
$('.menu-btn').click(function (e) {
  $('body').css('overflow', 'hidden');

/* Allow back page scrolling by clicking on the element with the necessary class name.
If you have several close elements with the same action like a close button and cancel button, write classes by a comma. */
$('.close-menu-btn, .menu-wrap').click(function (e) {
  $('body').css('overflow', 'auto');

See how this script works—all interactions except the script were made with Webflow built-in interactions 1.0.

It might be interesting for you

Let’s create together

Start a project

Let’s create together

What are your interested in?



Personal details

Thank you for getting in touch!
We appreciate you contacting us.
We will get back to you shortly.
Something went wrong while submitting the form.