2017-01-02 71 views
1

剛回來到編碼和我解決不了這個簡單的問題,所以任何幫助非常感謝。股利應高於其他分區,不低於

基本上「標題頂」(紅色)的div應在頂部,而「報頭底部的」(藍)的div應在底部。但是,頂級股利只是坐落在底部股利。爲什麼是這樣?我試過浮動,清除和保證金命令無濟於事。

謝謝。下面的代碼:

@charset "UTF-8"; 
 
/* CSS Document */ 
 

 
body{ 
 
\t background-color:#ff0; \t 
 
\t padding:0px; 
 
\t margin:0 auto; /* aligns content to touch the edge; gets rid of default spacing/margin between edge and content */ 
 
} 
 

 
/* Header */ 
 
#header-wrap{ 
 
\t background:#0F0; 
 
\t width:100%; 
 
\t height:auto; 
 
\t border-bottom: 3px solid #CCC; 
 
\t /* margin:0 auto; needed? */ 
 
} 
 
#header-top{ 
 
\t /* contains logo & title text */ 
 
\t background:#F00; 
 
\t width:960px; 
 
\t height:200px; 
 
\t margin:0 auto; /* aligns centrally */ 
 
} 
 
#header-bottom{ 
 
\t /* contains navigation menu */ 
 
\t background:#00F; 
 
\t width:960px; 
 
\t height:50px; 
 
}
<!doctype html> 
 
<html> 
 
<head> 
 
<meta charset="UTF-8"> 
 
<link rel="stylesheet" type="text/css" href="style.css"/> 
 
<!-- Meta Tags Below --> 
 
<meta name="description" content="" /> 
 
<meta name="keywords" content="" /> 
 
<title>___________________________</title> 
 
<!-- Google Analytics Code Below --> 
 
<!-- _____________________________ --> 
 
</head> 
 

 
<body> 
 
<div id="header-wrap"> 
 

 
<div id="header-top"> 
 
<div id="header-bottom"> 
 

 
</div> 
 
</body> 
 
</html>

+0

您需要將藍色div絕對定位 – slashsharp

+1

您的HTML不完整,您缺少關閉div標籤 – pol

回答

3

你有一個語法錯誤。請關閉div元素。

<div id="header-wrap"> 
    <div id="header-top"></div> 
    <div id="header-bottom"></div> 
</div>