如何使div id为蓝色占用容器div之后的剩余可见空间。此div也应该没有内容。
答案 0 :(得分:1)
使用此CSS:
/*add this:*/
html, body
{
height: 100%;
}
.clear
{clear:both;
display:block;
overflow:hidden;
visibility:hidden;
width:0;
height:0;
}
#blue
{width:100%;
background:blue;
/*and this*/height:100%;
}
要让浏览器检测到您要将蓝色div扩展为100%,您必须告知HTML和页面正文为100%,否则div无需引用百分比。
希望它可以帮助你。
答案 1 :(得分:1)
将css更改为:
#container{margin-left:auto;margin-right:auto;width:200px;}
html,body { height:100%; }
.clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0;}
#blue{width:100%;background:blue;height:100%;}
你也必须扩展页面的高度。
答案 2 :(得分:1)