2012-05-15 56 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