我有一个div:
clear:both;
position:absolute;
bottom:0;
left:0;
background:red;
width:100%;
height:200px;
和一个html,body:
html, body {
height:100%;
width:100%;
}
/* Body styles */
body {
background:url(../images/background.png) top center no-repeat #101010;
color:#ffffff;
}
我的代码基本上是20个loren ipsum段落,后面跟着div。
现在,我尝试将位置设置为相对和绝对等,但使用绝对时,div会将自己对齐到屏幕底部,因此当您向下滚动div时,会使用它进行滚动
我尝试将其设置为relative,但当没有足够的内容使页面滚动时,div不在页面底部。
我试着修好了,但还是修好了..对我没用
如何让div位于屏幕和页面的底部,这取决于是否有滚动
发布于 2011-06-23 08:07:37
好的,修复并工作:D希望它能做你想要的事情。在这里预览:http://jsfiddle.net/URbCZ/2/
<html>
<body style="padding:0;">
<div style="position:fixed; width:100%; height:70px; background-color:yellow; padding:5px; bottom:0px; ">
test content :D
</div>
<!--Content Here-->
</div>
</body>
</html>
发布于 2021-12-08 13:45:02
较短的解决方案:
.footer {
bottom: 0%;
position: fixed;
}
https://stackoverflow.com/questions/6447793
复制相似问题