我正在做一個CSS網站,我想看起來像這樣︰ 3個垂直格。 左中心右。在中心 div是網站內容,並且我希望左和右 div來填充中心和瀏覽器邊框之間的空間。製作一個網站與3格與中心內容和2個「緩衝區」填充通知水平空間
這是我的代碼。
#container
{
width:100%;
background-color:#000;
}
.center
{
width:1000px;
height:400px;
background-color:#F90;
margin: 0px auto;
overflow: auto;
}
.spacer-left
{
width:100%;
height:400px;
background-color:#F90;
float:left;
}
.spacer-right
{ width:100%;
height:400px;
background-color:#F90;
}
這裏是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>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Untitled Document</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div class="spacer-left"></div>
<div class="center" style="background-color:#F30;"></div>
<div class="spacer-right"></div>
<div style="clear:both"></div>
</div>
</body>
</html>
我嘗試用2周的div並沒有問題。左邊是float:左邊和右邊寬度,右邊是100%寬度,沒有浮動。有效。但如何使它與3個div。提前致謝!
偉大的維克多,如果問題解決了,你應該upvote並接受答案。 – 2010-11-20 22:13:50
如何做到這一點,因爲我不熟悉這裏的系統。 – Victor 2010-11-24 10:30:00