我能做的最好的事情就是将页脚推到页面底部,这样它就始终不在屏幕底部。以下是如何执行此操作的示例。stickyfooterfail 部门不起作用,我不知道为什么,但是bottom
如果您更改position
为绝对值,该属性确实可以正常工作。
<html>
<head>
<style type='text/css'>
body {
height: 100%;
}
#fullheight {
background:#ff0;
position: relative;
min-height: 100%;
}
#stickyfooterfail {
position: relative;
bottom: 0px;
}
#stickyfooter {
background: #f0f;
}
</style>
</head>
<body>
<div id='fullheight'>
Some text<br>
Some text<br>
Some text<br>
<div id='stickyfooterfail'>
Should be at the bottom but isn't
</div>
</div>
<div id='stickyfooter'>
This is pushed off the bottom by the min-height attribute of #fullheight
</div>
</body>
</html>
If you know that the footer is going to be a constant absolute size then you could set padding-bottom
to -(height) eg -40px if it was 40px high and then set bottom
of #stickyfooterfail to the same value.