<html>
<head>
<style>
/* main */
body {
margin: 0;
height: 100vh;
overflow-y: scroll;
scroll-snap-type: y mandatory;
}
div {
height: 100vh;
scroll-snap-align: start;
}
div:nth-of-type(2n+1) {
background: red;
}
div:nth-of-type(2n) {
background: blue;
}
</style>
</head>
<body>
<!-- <main> -->
<div></div>
<div></div>
<div></div>
<div></div>
<!-- </main> -->
</body>
</html>
Can anyone explain why this doesn't work if the scroll container is body?