我试图在具有动态高度(不断增长的内容)的div底部粘住页脚。 div需要浮动在页面中间(距离左右相同的距离)。HTML,CSS粘页脚(不断增长的内容)
我有以下的HTML(剥离不相关的东西):
<html>
<body>
<div class="bodybackground">
<div class="container"><!-- floats in the middle -->
<div class="mainContainer"><!-- different color etc -->
<!-- content with dynamic height -->
</div>
<footer class="pagefooter"></footer>
</div>
</div>
</body>
</html>
下面CSS(扒的不相干的东西):
html {
height: 100%;
margin: 0px;
padding: 0px;
}
body {
margin: 0px;
height: 100%;
}
.bodybackground {
height: 100%;
min-height: 100%;
}
.container {
min-height: 100%;
display: inline-block; /* needed make it float in the middle of body */
top: 0px;
position: relative;
padding: 0px;
padding-bottom: 158px; /* height of footer */
}
.mainContainer {
position: absolute;
height: 100%;
overflow: auto;
}
.pagefooter {
position: absolute;
bottom: 0px;
margin: 0px;
padding: 0px;
height: 158px;
}
然而mainContainer上的内容浮出并继续在页脚后面 - 而不是页脚处于最底部。除了那些强迫我改变容器显示属性的例子,我已经尝试过所有我能找到的东西,因为我需要将它保持在中间。
任何线索我在哪里白痴?谢谢!!
我需要使用.push更多一点,但是这解决了问题!感谢你及时的答复!