我正在尝试使用 CSS scroll-snap 使我的网站的用户体验更加愉快。虽然预期的滚动效果有效,但我的页脚在站点内的每个内容“页面”上都可见。这是基本结构:
<div class="main-scroll-container">
<div id="main-news">
</div>
<div id="main-footer">
</div>
</div>
<footer class="footer">
[...]
<footer>
CSS:
.main-scroll-container {
overflow: auto;
width: 100%;
height: 100vh;
scroll-snap-type: y mandatory;
scroll-snap-type: mandatory;
scroll-snap-points-y: repeat(100vh);
}
#main-news {
height: 100vh;
width: 100%;
background-color: [...]
scroll-snap-align: start;
}
#main-footer {
height: 100vh;
width: 100%;
background-color: [...]
scroll-snap-align: start;
}
我打算让滚动捕捉效果允许在代表页面底部的位置main-news
和main-footer
位置之间进行平滑更改。main-footer
在这部分中,我希望在底部有一个固定的页脚。我尝试了这两种方法position: absolute
以及position: relative
将bottom:0
页脚放入其中,main-footer
但页脚仍然出现在上 div 的底部main-news
。我真的很感激每一个帮助。