如何让div占据剩余高度? [英] How to make div occupy remaining height?
本文介绍了如何让div占据剩余高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个问题,我有两个div:
< div style =width:100% 50px; id =div1>< / div>
< div style =width:100%; id =div2>< / div>
如何让div2占据页面的剩余高度?
解决方案
使用绝对定位:
#div1 {width:100%; height:50px; background-color:red; / * Development Only * /}#div2 {width:100%; position:absolute; top:50px; bottom:0; background-color:blue; / * Development Only * /}
< div id =div1>< / div>< div id =div2>< / div>
/ div>I have this problem, I have two divs:
<div style="width:100%; height:50px;" id="div1"></div> <div style="width:100%;" id="div2"></div>
How do I make div2 occupy remaining height of the page?
解决方案Use absolute positioning:
#div1{ width: 100%; height: 50px; background-color:red;/*Development Only*/ } #div2{ width: 100%; position: absolute; top: 50px; bottom: 0; background-color:blue;/*Development Only*/ }
<div id="div1"></div> <div id="div2"></div>
这篇关于如何让div占据剩余高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文