时间:2021-07-01 10:21:17 帮助过:134人阅读
body,html{ min-height:100%;
}body{ position:relative;
}.content{ podding-bottom:100px;
}.footer{position:absolute;bottom:0;left:0;height:100px;
}这样写:
html {
height: 100%;
}
body {
position: relative;
min-height: 100%;
box-sizing: border-box;
padding-bottom: 80px; /* .footer 的高度,为 footer 占位 */}
.footer {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 80px;
}上面的代码兼容到 IE8 及以上
我也遇到过这样的问题,我就这样解决的了:
html,body,.content{
min-height:100%;
}
html{
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body{
background:#eeeeee;
}然后用js控制让$(".content").height($("html").height);我感觉这个调整比较可靠一点的
100%是根据他的父元素来做比较的,比如,
<div style="width:100px;">
<div style = "width:50%;"></div>
</div>回到楼主的问题,所以html只能设置固定的高度,设置body高度百分比的话,那你先设置html元素的高度!
以上就是css给body设置min-height为什么没有作用?的详细内容,更多请关注Gxl网其它相关文章!