2012-05-15 55 views
1

我是全新的HTML,所以我相信這是一個基本問題。列沒有完全跨越三列表

我有一個三列的表。我想要第一列跨越表格的40%,第二個30%和第三個30%。我有整個表格。但是,列不跨越整個表:

enter image description here

這裏是我的html:

<div class="TableWrap"> 
    <table id="PowerPlantTable" border="1"> 

     <thead> 
      <tr bgcolor="silver"> 
       <th class="firstColumn">Power Plant</th> 
       <th class="secondColumn">MW Output</th> 
       <th class="thirdColumn">MW Capacity</th> 
      </tr> 
     </thead> 

     <tbody> 
      <tr> 
       <td>BRUCEA-G2</td> 
       <td>0</td> 
       <td>0</td> 
      </tr> 
     </tbody> 
    </table> 
</div> 

,這裏是我的CSS:

.TableWrap{ 
    margin: 15px; 
    text-align: center; 
} 

#PowerPlantTable{ 
    display:block; 
    margin-left: auto; 
    margin-right: auto; 
    font-size:12.0px; 
} 

.firstColumn{ 
    width:40%; 
} 

.secondColumn{ 
    width:30%; 
} 

.thirdColumn{ 
    width:30%; 
} 

我在做什麼錯?

回答

1

從#PowerPlantTable中刪除display:block

表格默認爲display:table

+0

謝謝,修復它。 – Darren

+0

沒問題。我希望我有更多的解釋,爲什麼你遇到了你的行爲。我的猜測是,瀏覽器運行特定於渲染表格元素的算法,當表格沒有顯示爲表格時,它會對錶格中的「」和「​​」如何正確渲染感到困惑。 – Jrod