我在 Stack Overflow 上找到了很多关于固定页脚的解决方案,并且它们对我来说都有效。然而,我需要在我的“内容 div”和我的“页脚 div”之间保持60像素的距离。在我所找到的所有解决方案中,如果我为我的“页脚 div”设置 margin-top: 60px
,它没有起作用。
我找到的一个解决方案:
<div id="container">
<div id="body">
<div id="teste">
</div>
</div>
<div id="footer">
</div>
</div>
html,
body {
margin:0;
padding:0;
height:100%;
}
#container {
min-height:100%;
position:relative;
}
#teste {
background: red;
height: 500px;
}
#body {
padding:10px;
padding-bottom:60px; /* Height of the footer */
}
#footer {
position:absolute;
bottom:0;
width:100%;
height:60px; /* Height of the footer */
background:#6cf;
margin-top: 60px; <---- this didn't work
}