如果您正在尋找純粹的CSS,你可以做到以下幾點:
HTML文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="Stylesheet" href="Site.css" runat="server" rev="Stylesheet" type="text/css" />
</head>
<body>
<div id="Page">
<div id="Header">
This is my "Header Content"!
</div>
<div id="Content">
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content... This is my long content...
</div>
<div id="footer">
This is my "Footer Content"!
</div>
</div>
</body>
</html>
CSS(的site.css):
#Page
{
background-color: Red;
}
#Header
{
background-color: Purple;
color: White;
position: absolute;
left: 0px;
right: 0px;
top: 0px;
height: 75px;
font-size: xx-large;
text-align: center;
}
#Content
{
background-color: Lime;
position: absolute;
top: 75px;
left: 0px;
right: 0px;
bottom: 50px;
overflow: auto;
}
#footer
{
position: absolute;
text-align: center;
background: #66CCCC;
height: 50px;
bottom: 0px;
left: 0px;
right: 0px;
}
我當然要用奇怪的方式設置顏色和位置,以顯示div的相遇。將內容添加到頁面時,將其添加到內容區域,並且由於內容div爲overflow: auto;
,它將滾動並且頁眉/頁腳將爲靜態。
希望這會有所幫助!
這是修復它的最簡單的方法,但不幸的是它在IE6中不被支持,不幸... – peirix 2009-11-09 14:39:01
看看http://www.mozilla.org/causes/serviceweek/internethealth/。當然,你有權不同意他們寫的東西,但我也發現IE很噁心,不支持它。 – 2009-11-09 15:03:05
我當然意味着IE 6 ... – 2009-11-09 15:03:47