這裏是我的小提琴:DIv填充剩餘的垂直空間,即使div上面有動態高度?
<div id="wrapper">
<div id="yellow">variable height (I put 200px but can change in realtime)</div>
<div id="red">This one should fill all remaining space, even when yellow resizes</div>
</div>
html, body {
width:100%;
height:100%;
margin:0;
}
#wrapper {
width:100%;
height:100%;
position:relative;
}
#yellow {
width:100%;
height:200px;
background-color:yellow;
}
#red {
position:absolute;
top:200px;
bottom:0;
min-height;250px;
left:0;
width:100%;
background-color:red;
}
這工作好當黃色條具有靜態的高度,這是不是在我的情況下工作。
(不使用JS拜託了!)
[重複的問題(HTTP: // STA ckoverflow.com/questions/90178/make-a-div-fill-the-height-of-the-remaining-screen-space) –
或也是這一個http://stackoverflow.com/questions/25098042/fill-剩餘的垂直空間與 - CSS-使用-displayflex/25098486 –