我有一个似乎无法解决的问题。
我有一个设置为 position: absolute
的大背景横幅,问题是,我希望我的页脚始终位于其下方 - 无论横幅的高度如何。
一个例子:
页脚看起来不错:http://danne-bro.com.web122.curanetserver.dk/histor.aspx
页脚不合适:http://danne-bro.com.web122.curanetserver.dk/who.aspx
正如您在源代码中看到的那样,我已经尝试了很多事情。我想要完成的内容的一个删减版本是这样的:
<div id="fit">
<div class="wrapper">
<div id="banner">BANNER IN HERE - Position Absolute so its always underneath</div>
</div>
<div class="wrapper">
All content goes here - which is on top of the banner
</div>
</div>
<div id="footer">
Footer in here - should float right under the banner.
</div>
但是如何让页脚保持在横幅下方(无论它的高度如何)对我来说是个问题。我希望我对自己的解释足够好。
最佳答案
您不能 float
绝对定位
元素,因为当您使用position: absolute;
时,您的元素脱离了文档流,您需要使用 top, left, right, bottom 来定位它, float 不会在绝对上工作,或多或少你可以做的是在 position: relative;
容器内使用绝对定位的 div,或者尝试使用 ryan fait 的 sticky footer
关于html - 在绝对位置下 float ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13759695/