gpt4 book ai didi

html - 防止在固定位置元素后面滚动

转载 作者:太空宇宙 更新时间:2023-11-04 01:33:13 34 4
gpt4 key购买 nike

我在页面底部固定了一个页脚,并设置了高度。是否可以滚动我的页面内容,使其在固定页脚的顶部结束?

我的问题在这里:fiddle

非固定元素的最后 250 像素(页脚高度)滚动到页脚后面,当滚动条到达页面底部时看不到。

<div style="height: 500px; width: 50%; background-color: yellow;"></div>
<div style="height: 500px; width: 50%; background-color: blue;"></div>
<div style="height: 500px; width: 50%; background-color: green;"></div>

<div style="position: fixed; width: 100%; height: 250px; bottom: 0; background-color: #ccc;">
Fixed Footer
</div>

最佳答案

这是您需要做的事情,但是您需要编写 CSS,如果您单独编写 CSS 而不是将样式属性赋予 div 会更好。

In order to fix your problem we need to set overflow to be hidden Learn more about these properties here.

body,
html{
overflow: hidden;
margin: 0;
padding: 0;
}
<div style="height: 500px; width: 50%; background-color: yellow;"></div>
<div style="height: 500px; width: 50%; background-color: blue;"></div>
<div style="height: 500px; width: 50%; background-color: green;"></div>

<div style="position: fixed; width: 100%; height: 250px; bottom: 0; background-color: #ccc;">
Fixed Footer
</div>

关于html - 防止在固定位置元素后面滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46713072/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com