【发布时间】:2016-04-26 15:32:47
【问题描述】:
所以我一直在互联网上四处寻找解决方案,以使页脚保持在页面的最底部,而不管页面内容的长度如何。我按照教程中的CSS,如果内容不够长,页脚只会在页面底部,如果内容太长,页面会得到滚动条,页脚会卡在中间向下滚动页面以获取更多内容。下面是我的 CSS 和 HTML。
body,html{
background-color:#fff;
width:100%;
height:100%;
margin:0px;
padding:0px;
}
.wrapper {
position:relative;
top:0px;
width:100%;
min-height:100%;
padding:0px;
margin:0px;
}
.country-container {
position:absolute;
top:100px;
left:20%;
width: 1024px;
height:1300px;
background:blue;
}
.container {
position:absolute;
top:0px;
left:20%;
width: 1024px;
height:86px;
max-height:300px;
background:blue;
}
#footer{
position:absolute;
bottom:0px;
width:100%;
height:100px;
max-height:900px;
left:0px;
color:#000099;
background:#f2f2f2;
}
Now this is my html, the two absolute positioned divs and the footer are inside the wrapper which has position relative.
<html>
<body>
<div class="wrapper">
<div class="container">Container 1</div>
<div class="country-container">Container 2</div>
<div id="footer">Footer</div>
</div>
</body>
</html>
【问题讨论】: