您可以使用Flex屬性執行此操作。
小提琴:https://jsfiddle.net/9vq8nkpc/
HTML
<div id="container">
<div id="top">
top variable height
</div>
<div id="bottom">bottom variable heighbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightbottom variable heightt</div>
</div>
CSS
#container {
border: 1px solid red;
height: 200px;
position: absolute;
display:flex;
flex-direction:column;
justify-content:space-between;
}
#top, #bottom {
border: 2px solid red;
background: #ccc;
width:80%;
display: inline-block;
}
所以,你要'#bottom'到'#高度後佔據'#container'內的任何剩餘寬度頂部'已被考慮到? – BenM
我忘了提及任何解決方案都必須在IE8中工作,而無需額外的jQuery,比如css pie或其他。 – Adyyda