对于放置在窗口顶部或某处的分区,我们将为其提供一些相对余量。有什么方法可以将 div 设置在底部,就像页脚上方一样?我会解释我的问题:
我有一个页脚。
我有一个 height = 200px 的 div
我有另一个 height = 400px 的 div
现在我想把它们放在窗口中,这样它们看起来就像放在页脚上一样。我怎样才能做到这一点?谢谢
最佳答案
你的主要内容应该是这样的:
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -40em; /* The -40em should be adjusted to your page, just play around with it */
}
然后是你的 div heitgh200、div height400 和页脚。
这是一个完整的工作示例:
这是关于粘性页脚的一个很好的教程:http://ryanfait.com/resources/footer-stick-to-bottom-of-page/
关于css - 如何将div定位在窗口底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16639163/