私は css サイトを作成していますが、次のように表示したいと考えています: 3 つの垂直 div。左中央右。中央のdiv にはサイト コンテンツがあり、中央とブラウザの境界線の間のスペースを左右のdiv で埋める必要があります。
これが私のコードです。
#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:left とピクセル単位の幅、右は float なしの 100% 幅です。出来た。しかし、3 divでそれを作る方法。前もって感謝します!