我試圖佈置一個網站:流體寬度/ CSS問題
http://kenzshop.com/Brandon/index
我不能讓主內容區域(藍色)正確對齊。 (紅色)有一個流體,側邊欄(黃色)有一個流體高度,主要內容區應該是流體寬度和高度,但我無法弄清楚如何使它正確對齊。
它應該在寬度方向上與標題對齊。
任何人都可以看到我的問題是什麼?
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 of document</title>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8"></meta>
<meta http-equiv="Content-Type" content="text/css; charset=utf-8"></meta>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header"></div>
<div id="main"><!--<iframe src="http://www.cnn.com/"/> --></div>
<div id="sidebar"></div>
</body>
</html>
CSS:
body {
margin:0;
padding:0;
height:100%;
}
#header{
height: 80px;
border: 1px solid black;
padding: 5px;
margin-top: 5px;
margin-left: 5px;
margin-right: 5px;
background-color:red;
}
#main{
position:absolute;
left:0;
top:90px;
right: 263px;
padding:0;
margin-top: 12px;
margin-left: 5px;
margin-bottom:5px;
height:99% !important; /* works only if parent container is assigned a height value */
width:100%;
border:1px solid black;
background-color:blue;
}
iframe{
margin: 5px;
display:block;
width:100%!important;
height:100%!important;
}
#sidebar{
position:absolute;
right:0;
top:102px;
padding:0;
margin-right:5px;
margin-bottom:5px;
width:250px;
height:99%; /* works only if parent container is assigned a height value */
border:1px solid black;
background-color:yellow;
}
你能給我更詳細意味着什麼「對齊正確「? –
剛剛上傳了一張圖片以顯示更好;)謝謝,Ken – Ken
另外,新網頁不應該使用過渡文檔類型。 Transitional適用於在過渡到嚴格時包含較舊的棄用標記的那些頁面。但是你不應該使用不贊成的標記。 – Rob