2012-05-27 42 views
0

我正在創建一箇中心區域爲800px的網頁。如果分辨率更高,「側邊欄」將以另一種顏色呈現。我有這樣的代碼:根據屏幕分辨率的CSS高度

body { 
    width: 800px; 
    height: auto; 
    ... 
} 

我希望當內容非常小時,中心區域會一直延伸到頁面結尾。做這個的最好方式是什麼?

+1

這是一個平常的問題。此鏈接可能會幫助你:http://stackoverflow.com/questions/485827/css-100-height-with-padding-margin。 –

回答

1

,你唯一能做的事情會是這樣的:

<style type="text/css"> 
    html, body, .container { 
    height: 100%; 
    width: 800px; 
    margin: 0 auto; 
    } 
    .container { 
    background: yellow; 
    } 
</style> 

而且......

<body> 
    <div class="container"> 
    dewdewd 
    </div> 
</body>