http://cdpn.io/FykHr 我似乎对组合的CSS属性有问题:
position: absolute;
bottom: 0;
Run Code Online (Sandbox Code Playgroud)
首先,您可以看到.footer div不在底部.现在,将font-sizefrom 更改为120px,50px并且div似乎按照我的方式工作.
无论.content div的大小如何,如何使.footer div保持在底部(不固定在屏幕底部).
有一种方法可以做到这一点:
body {
height: 100%;
margin: 0;
}
html {
padding-bottom: 50px;
min-height: 100%;
box-sizing: border-box;
-moz-box-sizing: border-box;
position: relative;
}
footer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 50px;
background-color: red;
}
Run Code Online (Sandbox Code Playgroud)
还有一个限制.您必须知道页脚的高度并将其设置在两个位置.