這裏走出來的我有我的網頁的計劃:600×800個像素HTML頭不正確的寬度
- 車身寬度x高度;沒有襯墊,因此如果它們沒有邊距,它裏面的元素可以緊貼在牆上。
- 身體內的3個元素:標題,主要內容和頁腳,這些都被視爲類(因爲我將在我的網站的多個頁面上使用相同的佈局)。
- 3個元素的寬度將分別爲598像素,邊距爲0像素,邊框爲1像素,因此它們完全適合身體。邊框將虛線以添加視覺上下文。
- 這3個元素'將通過150,500和150各自的像素來劃分身體的高度。它們的1像素底部/頂部邊框將重疊。因此頁面的垂直空間將是頂部的1像素邊界,148個像素的空間,1個邊界像素,499個像素的空間,1個邊界像素,149個像素的空間以及最後1個邊界像素底部。
如果可以,請向我解釋我在執行HTML邏輯時出錯的地方。預覽頁面時,我的標題不是正確的寬度。 (顯然,我的網頁去看看多彩的和動態的,當我完成它。現在我只是試圖讓佈局正確的。)
<html>
<head>
<title>div practice</title>
<style type="text/css">
body
{
padding: 0px;
height: 800px;
width: 600px;
}
.header
{
margin: 0px;
border: 1px dashed;
width: 598 px;
height: 148px;
position: absolute;
top: 0px;
left: 0px;
}
.mainContent
{
margin: 0px;
border: 1px dashed;
width: 598px;
height: 500px;
position: absolute;
top: 148px;
left: 0px;
}
.footer
{
margin: 0px;
border: 1px dashed;
width: 598px;
height: 148px;
position: absolute;
top: 648px;
left: 0px;
}
</style>
</head>
<body>
<div class="header">
<p>This is where the header goes</p>
</div>
<div class="mainContent">
<p>This where the main content goes</p>
</div>
<div class="footer">
<p>This is where the footer goes</p>
</div>
</body>
</html>
1,請永遠不要把一個高度爲您的內容,這一點都不好,會給你帶來問題。 – SULTAN
如果我可能會問什麼問題? – user3461018
,因爲如果您的內容會超出您定義的高度,則會覆蓋您的樣式。看到這個例子:http://jsfiddle.net/salota8550/F7rF6/ – SULTAN