table-layout:修复问题

时间:2012-03-01 06:32:52

标签: css tablelayout

我有一个table,表格布局已修复。表中有2列。

如果我为第一行设置colspan=2,那么对于剩余的行,它显示相等的宽度。 (它没有采用我指定的宽度。)

小提琴附件here

<table style='table-layout:fixed' border="1" width="100%">
  <thead>
    <tr>
      <th colspan='2'>10000</th>
    </tr>
    <tr>
      <th width="5%">1066fdg</th>
      <th width="95%">10</th>
    </tr>
  </thead>
</table>

是否有为剩余的行设置指定的列宽?

3 个答案:

答案 0 :(得分:6)

这是因为固定表格布局是由第一行OR列定义驱动的 - 试试这个

<table style='table-layout:fixed' border="1" width="100%">
<col width="5%" />
<col width="95%" />
<thead>
<tr>
<th colspan='2'>10000</th>
</tr>
<tr>
<th>1066fdg</th>
<th>10</th>
</tr>
</thead>
</table>

答案 1 :(得分:0)

您在th上设置了宽度,为什么不在样式表中设置一个类,以便为thtr行提供所需的宽度?

答案 2 :(得分:0)

试试这个

<table style='table-layout:fixed' border="1" >
<col width="5%" />
<col width="95%" />
<thead>
<tr>
<th colspan='2'>10000</th>
</tr>

<tr>
<th>1066fdg</th>
<th>10</th>
</tr>
    <tr><th>&nbsp</th><th>&nbsp</th></tr>
</thead>
</table>