我不明白身高百分比是如何运作的。
为什么下面的片段没有填充颜色?
body {
height: 100%;
}
#div1 {
height: 20%;
background-color: red;
}
#div2 {
height: 80%;
background-color: blue;
}
<div id="div1"></div>
<div id="div2"></div>
你必须设置html
's height
以及。
html,
body {
height: 100%;
margin: 0;
}
#div1 {
height: 20%;
background-color: red;
}
#div2 {
height: 80%;
background-color: blue;
}
<div id="div1"></div>
<div id="div2"></div>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)