小编典典

如何使div占据剩余高度?

html

我有这个问题,我有两个股利:

<div style="width:100%; height:50px;" id="div1"></div>
<div style="width:100%;" id="div2"></div>

如何使div2占据页面的剩余高度?


阅读 796

收藏
2020-05-10

共1个答案

小编典典

使用绝对定位:

#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>
2020-05-10