Set width on which under with colspan

后端 未结 2 1592
既然无缘
既然无缘 2021-01-03 14:27

I\'d like to set width on the td in tbody which is underneath thead that has colspan=\"2\" with an hard defined column wi

相关标签:
2条回答
  • 2021-01-03 14:53

    just change your css that is so confusing for me. change it to follow

     .sample {width: 100%;}
    .sample td:nth-child(1) {width:30%;}
    .sample td:nth-child(2) {width:70%;}
    

    of you wish that table looks good then you can give border so that u have clear idea about it.

    <table class="sample" border="1px grey solid">
    ..
    </table>
    
    0 讨论(0)
  • 2021-01-03 15:09

    Try using <colgroup> and <col> tags:

    .sample {
      width: 100%;
      table-layout: fixed;
    }
    <table class="sample" border="1">
      <colgroup>
        <col style="width:30%;">
        <col style="width:70%;">
      </colgroup>
      <thead>
        <tr>
          <th colspan="2">Header</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>30%</td>
          <td>70%</td>
        </tr>
      </tbody>
    </table>

    0 讨论(0)
提交回复
热议问题