下面是HTML代碼:CSS佈局:高度100%的div(裏面還有更多的div)有兩個固定的高度divws
<div id="header">
</div>
<div id="container">
<div id="leftbar">
</div>
<div id="content">
</div>
</div>
<div id="footer">
</div>
,這裏是我想要的東西,以實現的,即使它是不是有效CSS,但我想你會明白我的觀點:
html,body
{
min-width:800px;
max-width:1680px;
width:100%;
height:100%
}
#header
{
width:100%;
height:100px;
background:#CCCCCC url(images/header_bg.gif) repeat-x;
}
#footer
{
width:100%;
height:10px;
}
#container
{
width:100%;
height:100%-100px-10px; /* I want #container to take all the screen height left */
}
#leftbar /*fixed width, the height is always the same as the screen height*/
{
height:100%;
width:200px;
}
#content
{
height:100%;
width:100%-200px; /* take all the screen width left except the leftbar */
overflow:auto;
}
有人只是把這個作爲一個例子: http://limpid.nl/lab/css/fixed/header-and-footer
我不認爲使用<body>padding
到排除頁眉和頁腳是一個很好的途徑,因爲我希望所有滾動條都出現在div#內容中,而不是用於整個<body>
標記。
你能更具體嗎?爲div#內容提供「margin-left:200px」?在這種情況下,div#內容的寬度是多少,如果它是默認的100%,則沒有辦法將這兩個div並排放置。 – WilliamLou 2009-12-17 22:22:56