2013-02-02 137 views
3

我確信這是我正在做的一些愚蠢的事情,但是這已經有一段時間了,因爲我搞砸了CSS。而對於我的生活,我無法弄清楚爲什麼div盒沒有顯示正確的高度(如CSS中所指定的)......爲什麼在標題div和列之間有黑色塊空間。被忽略的Div標籤的高度

任何幫助將非常感謝!我知道這是相當簡單的,我只是試圖讓主要佈局下來。

感謝您的任何幫助! CSS:

#container { width: 1000px; margin: 30px auto 60px;} 

    h1 { text-align: center;} 

    #header { height: 200 px; width: 1000 px; background-color: #993300} 
    #mcol1 { height: 600; width: 500px; float: left; background-color: #2a9c3b;} 
    #mcol2 { height: 600; width: 500px; float: left; background-color: #996666;} 

HTML:

<div id="container"> 

<div id="header"> 
<h1> Name</h1> 
</div> 
<div id="mcol1"> 
<h1>Test1</h1> 
</div> 

<div id="mcol2"> 
<h1>Test2</h1> 
</div> 
</div> 

</body> 

既然不能直接發佈照片,因爲我是新的,下面就來它是如何顯示的鏈接:http://imgur.com/gW0vY7a 謝謝!

回答

2

height: 200 px; 
height: 200; 

height: 200px; 
+0

謝謝大家!我認爲這解決了它,儘管我也實施了明確的解決方案。我相信在某個時候我會有更多的問題。這個社區真棒!我期待着更多參與! – user2035758

3

添加px每一個高度值:

#header { height: 200px; width: 1000px; background-color: #993300} 
#mcol1 { height: 600px; width: 500px; float: left; background-color: #2a9c3b;} 
#mcol2 { height: 600px; width: 500px; float: left; background-color: #996666;} 

jsfiddle

0

嘗試通過使用該清除mcol1和mcol2彩車:

  <!-- html --> 
      <div id="container"> 

      <div id="header"> 
       <h1> Name</h1> 
      </div> 
      <div id="mcol1"> 
       <h1>Test1</h1> 
      </div> 

      <div id="mcol2"> 
       <h1>Test2</h1> 
      </div> 
      <div class="clear"></div> 
      </div> 

      <!-- css --> 
      .clear{ 
      clear:both; 
      height:0; 
      line-height:1px; 
      } 
      #mcol1 { height: 600px; width: 500px; float: left; background-color:#2a9c3b;} 
      #mcol2 { height: 600px; width: 500px; float: left; background-color: #996666;} 
0

此外,您可能要添加樣式溢出隱藏你的div尤其是在Internet Explorer中的小的div

style = "overflow: hidden;" 

和你也可能想要下載reset.css並將它包含在頭裏

<link rel = "stylesheet" type = "text/css" href = "css/reset.css"/>