Is there a way to prioritize horizontal scrolling on mobile for a slider in Webflow, without triggering a vertical scroll?

Published on
September 22, 2023

Yes, there is a way to prioritize horizontal scrolling for a slider on mobile without triggering a vertical scroll in Webflow. By default, Webflow's slider component allows for both horizontal and vertical scrolling on mobile devices, which can sometimes lead to conflicts and unwanted scrolling behavior. To prioritize horizontal scrolling and prevent vertical scrolling, you can use custom CSS and Webflow's interactions to achieve the desired effect. Here's how:

  1. Select the slider element in the Webflow designer.
  2. Go to the Styles panel on the right-hand side and add a new custom CSS class (e.g., "horizontal-slider").
  3. In the custom CSS class, add the following code:
.horizontal-slider {    overflow: scroll;    overscroll-behavior-y: contain;    -webkit-overflow-scrolling: touch;    touch-action: pan-y;}

This CSS code ensures that the slider element has horizontal scrolling behavior and prevents vertical scrolling.

  1. Next, create a new interaction by selecting the slider element and going to the Interactions panel.
  2. Click on the "+" button to add a new action and choose "While scrolling in view" as the trigger.
  3. In the action settings, add a new step with the following properties:
  • Scroll trigger: Set to "None"
  • Property: Scroll
  • Direction: Vertical
  • Duration: 0ms
  • Easing: Linear
  • Limit: 0
  • Disabled: Unchecked
  1. Save the interaction and publish your site to see the changes take effect.

By using this custom CSS class and interaction, you'll be able to prioritize horizontal scrolling for the slider on mobile without triggering a vertical scroll. Users will now have the ability to swipe horizontally through the slider content without encountering unwanted vertical scrolling.

Additional Resources:

Q: How can I disable vertical scrolling for a specific element in Webflow?
Q: Can I customize the scroll behavior on a mobile device using Webflow?
Q: Is it possible to create a horizontal-only slider in Webflow?