web - css 百分比高度的div 撑不开怎么办
本文介绍了web - css 百分比高度的div 撑不开怎么办的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
html,body {
width:100%;
height:100%;
}
.center {
width:80%;
margin:auto;
}
#top {
height:20%;
background-color:yellow;
}
#module {
height:60%;
background-color:gray;
}
#bottom {
height:20%;
background-color:blue;
}
<body>
<div id="top" class="center"></div>
<div id="module" class="center">
<div id="bottom" class="center"></div>
<div id="bottom" class="center"></div>
<div id="bottom" class="center"></div>
<div id="bottom" class="center"></div>
<div id="top" class="center"></div>
<div id="top" class="center"></div>
<div id="top" class="center"></div>
<div id="top" class="center"></div>
<div id="top" class="center"></div>
<div id="top" class="center"></div>
</div>
<div id="bottom" class="center"></div>
</body>
上面就是上面代码的问题 中间的div 不能被内部的DIV撑开 怎么办呢
我将
#module {
height:60%;
background-color:gray;
}
中高度去掉后 还是不能撑开 而且里面的DIV的高度也没有了
我后来发现是因为加了<!DOCTYPE html>
的缘故 请问为什么呢
解决方案
#module {
background-color:gray;
}
去掉height:60%; 就撑开了
这篇关于web - css 百分比高度的div 撑不开怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文