在没有看到小提琴的情况下,我的第一个想法就是完全按照您所说的去做:增加底部 div 的高度以覆盖多余的滚动。像这样:
.bottom-container {
position: relative;
height: /* current height + overflow amount of height */
top: /* overflow amount of height */
}
所以如果你的底部容器是 400px:
.bottom-container {
position: relative;
height: 600px;
top: 200px;
}
只要没有overflow: hidden
应用于页面,这样的东西理论上应该可以工作。
body {
margin: 0;
padding: 0;
}
.fixed-background {
position: fixed;
height: 100vh;
width: 100%;
background: tomato;
}
.fixed-placeholder {
height: 100vh;
background: transparent;
}
.bottom-container {
position: relative;
height: 400px;
width: 100%;
background: white;
top: 200px;
}
<div class="fixed-background">
<h1>Fixed Background</h1>
</div>
<div class="fixed-placeholder"></div>
<div class="bottom-container">
<h2>More content down here</h2>
</div>