表格布局:已修复问题

问题描述 投票:0回答:3

我有一个

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

如果我为第一行设置

colspan=2
,那么对于其余行,它显示相同的宽度。 (它没有采用我指定的宽度。)

小提琴附这里

<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>

有没有办法为剩余的行设置指定的列宽?

css tablelayout
3个回答
6
投票

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

<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>

0
投票

您在

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


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>
© www.soinside.com 2019 - 2024. All rights reserved.