Comment by vintagedave
1 month ago
The trick to prevent scrolling by setting overflow: hidden unfortunately results in visual page jumping for me.
The reason is I have macOS set up to always show scroll bars, instead of hiding them. At least one browser (I forget which, but I test on Safari, Firefox and Chrome) doesn’t have a disabled scroll bar but removes it altogether. This makes the page wider and causes it to reflow and move.
Does anyone know how to keep the scroll bar onscreen, just not enabled?
It's been a while since I've tested this, but an explicit overflow-y: scroll used to keep the scrollbar there, so that when you needed to change the property, the user-agent controls wouldn't pop in or out.
yes, "html { overflow-y: scroll }" works.
Website authors can set a scrollbar gutter.
scrollbar-gutter: stable; to those unfamiliar. https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-g...
Man, this makes me feel old.
This is only recently supported by all major browsers thanks to the interop efforts. pre-2024 browser versions will not support this