Developers working on macOS should change a system setting before shipping layout work: System Preferences > General > Show scroll bars, set to always. The reason is not personal preference but exposure — with the setting off, scrollbar-driven layout shifts never show up locally, while users who keep it on will see them. Designing around that jank requires running into it in the first place.
Stefan Judis demonstrated one common trigger, where viewport units contribute to the problem:
Today I learned a little CSS fact I wasn't aware of. Viewport units are not taking scrollbars into consideration and can trigger overflows easily.
— Stefan Judis (@stefanjudis) August 22, 2021
Found on the @polypane blog: https://t.co/RpTnwzrYcA
Video alt: Example showing that 100vw can trigger overflows. pic.twitter.com/JXakqV3Vna
In that case 100vw produces horizontal overflow, because the vertical scrollbar already occupies part of the viewport width. It is a counterintuitive outcome.
Established workarounds
Stefan points to Kilian Valkhof's article on handling horizontal overflows, which collects the classic fixes:
The easy fix is to use
width: 100%instead. Percentages don’t include the width of the scrollbar, so will automatically fit.If you can’t do that, or you’re setting the width on another element, add
Kilian Valkhof, “How to find the cause of horizontal scrollbars”overflow-x: hiddenoroverflow: hiddento the surrounding element to prevent the scrollbar.
Both approaches carry a hack quality, since neither matches the original intent exactly.
A spec-level fix
A standards-based solution is on the way, as Bramus Van Damme explains:
A side-effect when showing scrollbars on the web is that the layout of the content might change depending on the type of scrollbar. The
Bramus Van Damme, “Prevent unwanted Layout Shifts caused by Scrollbars with thescrollbar-gutterCSS property —which will soon ship with Chromium — aims to give us developers more control over that.scrollbar-gutterCSS property”
The property is a plausible candidate for inclusion in reset stylesheets:
body {
scrollbar-gutter: stable both-edges;
}
Open questions
One detail is worth checking: at the whole-page level, the property belongs on the <body> element rather than <html>, which has historically behaved inconsistently for scrolling-related properties. Cross-browser adoption remains uncertain. The behavior is specified, though, and the property is friendly to progressive enhancement, so the case for using it holds even before support is universal.



