Seems to me like a pretty basic scroll-snapping setup, but it allow for boundless scrolling in Google Chrome (desktop):
In the above you can see that from the top of the page, you can still scroll up further. Equally, from the bottom of the page you can still scroll down further.
(bug observed in Google Chrome 131.0.6778.86 on MacOS)
Simplified code:
HTML:
<html>
<body>
<div class="a"></div>
<div class="b"></div>
</body>
</html>
CSS:
html {
scroll-snap-type: y mandatory;
}
.a {
scroll-snap-align: start;
height: 100vh;
}
.b {
scroll-snap-align: start;
height: 33.3vh;
}
I’ve tried a multitude of approaches and haven’t managed to find a fix that doesn’t also inadvertently remove scroll-snapping. I’m hoping one of you wizards has some obscure CSS-property that forces Google Chrome into honoring the scroll-boundaries of the document.
2
Answers
Add
overflow-y: scroll
to both thehtml
andbody
elements, and setheight: 100%
on the body. This combination creates a proper scroll container that respects document boundaries. Here’s the enhanced css:styles.css
This approach works by explicitly defining the scrollable area and ensuring the browser has clear boundaries for the scroll container. The
height: 100%
on the body element ensures proper content containment, whileoverflow-y: scroll
on both html and body elements creates a well-defined scrolling context that prevents the overscroll behavior you’re experiencing.Use a wrapper instead of setting it into the
:root
like so.Found on this reddit post.
https://www.reddit.com/r/css/comments/i9kkiw/scroll_snap_bug_chrome_on_mac/.