当网页内容区content东西很少时,footer就会跑到上边来?
我给body,html设min-height:100%;没有作用,
设置height:100%;就好了,但是内容多了就在一屏下?
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为什么没有作用?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号