任何想法如何使下面的代碼中的中間部分(jsFiddle here)適應實際容器的高度而不指定固定值或Javascript?在這個小提琴中,我嘗試設置容器的絕對和相對值,但頁面始終顯示垂直滾動條,因爲容器的高度超出了實際頁面的高度。不同頁面大小的靈活DIV高度
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
body { margin: 0; height:100%;}
#mainContainer { position: absolute; right: 4%; left: 4%; height: 100%; }
#headerContainer { width: 100%; position: relative; background: #323232; color: white; height: 30px; }
#middleContainer { height: 100%; }
#leftSection { position: absolute; float: left; width: 175px; background: #71ABD1; height: 100%; overflow: auto; color: black; }
#middleSection { position: absolute; height: 100%; background-color: yellow; left: 175px; right: 175px; color: black; }
#rightSection { float: right; height: 100%; width: 175px; border-left: 1px dotted black; background: red; color: black; }
#footerContainer { position: relative; width: 100%; height: 30px; background: #323232; color: white; }
</style>
</head>
<body>
<div id="mainContainer">
<div id="headerContainer">
headerContainer
</div>
<div id="middleContainer">
<div id="leftSection">
<div style="margin-top: 30px;">leftSection</div>
</div>
<div id="middleSection">
<div style="margin-top: 30px;">middleSection</div>
</div>
<div id="rightSection">
<div style="margin-top: 30px;">rightSection</div>
</div>
</div>
<div id="footerContainer">
footerContainer
</div>
</div>
</body>
</html>
您是否試圖讓中間div與瀏覽器窗口一樣高,或者這是一個簡單的虛擬列問題? –
兩者,我需要中間div伸展到窗口的高度(這將導致包含的左,中,右列伸展到高度),同時保持頁眉和頁腳div的地方。 – Maya