HTML-CSS实现 | 在页面不满时,footer也为于底部
代码中的div要为footer的父框
html{
height: 100%; /*保证页面高度撑满屏幕*/
}
body{
height: 100%;
}
body>div{
/*保证footer是相对于div位置绝对定位*/
position:relative;
width:100%;
min-height:100%;
/*设置padding-bottom值大于等于footer的height值,以保证main的内容能够全部显示出来而不被footer遮盖;*/
padding-bottom: 100px;
box-sizing: border-box;
}
footer的样式
footer{
position:absolute; /*footer在div的底部*/
bottom:0px;
width: 100%;
}
内容会不断更新,欢迎批评指正。

浙公网安备 33010602011771号