我想创建一个网站。有多个部分,宽度为 100vw,高度为 100vh。我还想要这些部分的强制 y(垂直)捕捉。我检查了很多教程,但我的代码似乎不起作用。非常感谢任何帮助。
当前代码
body {
width: 100%;
margin: 0;
background-color: white;
}
body .content {
width: 100vw;
height: 100%;
scroll-snap-type: mandatory;
scroll-snap-points-y: repeat(300px);
scroll-snap-type: y mandatory;
}
body .content section {
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
border: 1px solid black;
scroll-snap-align: start;
}
<div class='content'>
<section>1</section>
<section>2</section>
<section>3</section>
<section>4</section>
</div>