gpt4 book ai didi

html - 溢出不起作用 - 文件高度增长

转载 作者:太空宇宙 更新时间:2023-11-03 21:49:59 25 4
gpt4 key购买 nike

我很困惑为什么这一小段 html + css 使我的 $(document).height() 变得巨大。似乎溢出容器没有完全工作。这是一个显示错误行为的 jsbin:http://jsbin.com/omokin/1

<html>
<head>
<style>
#container {overflow:auto;height:500px;width:300px;}
#big {height:90000px;background-color: pink;}
</style>
</head>
<body>
<div id="container">
<div id="big">
</div>
<div style='visibility:hidden; position:absolute;'>x</div>
</div>
</body>
</html>

最佳答案

因为你在大div下面的容器里放了一个position:absolute的div。当您向下滚动到示例中的页面底部时,您会注意到带有 x 的隐藏 div 就在那里。

http://jsbin.com/omokin/6/

如果稍微改变顺序,position:absolute 将不会将整个页面向下推。

<div id="container">
<div style='visibility:hidden; position:absolute;'>x</div>
<div id="big">
</div>
</div>

换句话说,您不能在您使用的上下文中使用绝对位置。您需要删除绝对定位或将该 div 移动到大 div 之上。

关于html - 溢出不起作用 - 文件高度增长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18039207/

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