Horizontal scrolling and layout shift on mobile usually happen due to elements extending beyond the viewport width. Here's how to fix this in Webflow.
1. Identify Overflowing Elements
- Enable Overflow Indicators in Designer by selecting the Navigator panel and checking each element’s width, margin, and padding settings.
- Use Chrome DevTools (Inspect Element) and toggle the mobile view. Scroll sideways to spot what’s leaking out of the container.
2. Set Overflow to Hidden
- Select the parent elements such as
body or main wrapper in Webflow. - In the Style panel, set Overflow: Hidden on the X-axis to prevent horizontal scroll:
- Go to Styles Panel > Layout > Overflow and choose Hidden.
3. Check Element Sizes
- Ensure no elements are wider than the mobile viewport:
- Avoid fixed widths (e.g.,
100vw) that ignore potential scrollbar widths. - Use 100% width instead of 100vw when possible.
- Check for large images, buttons, or custom code embeds that could exceed the mobile screen width.
4. Fix Issues with Negative Margins or Padding
- Negative margins or padding can push content outside the visible area.
- Review all elements (especially in mobile breakpoints) for:
- Negative margins, especially on horizontal sides.
- Excessively large positive left/right padding.
5. Use CSS Grid or Flexbox Responsibly
- Make sure Grid or Flexbox layouts don’t generate widths larger than intended.
- Check that Flex Children are not set to “Don't Shrink” if they are wider than their container.
6. Test and Preview on All Breakpoints
- In Webflow Designer, click on each breakpoint icon (Desktop, Tablet, Mobile Landscape, Mobile Portrait).
- Make sure layouts render correctly across all sizes.
7. Remove or Adjust Custom Code
- If you’ve added embeds, scripts, or iframes, make sure they are responsive:
- Use styling attributes like
max-width: 100% and height: auto for images and videos. - Add
overflow-x: hidden to the <body> tag via Custom Code > Inside <style> in Head if needed.
Summary
To prevent mobile layout issues and horizontal scrolling in Webflow, check for overflowing elements, set horizontal overflow to hidden, and ensure all items are sized responsively. Make these adjustments carefully across all responsive breakpoints and test thoroughly in both Webflow Preview and actual mobile devices.