csstablelayout

table-layout:fixed issue


I have a table with table-layout fixed. There are 2 columns in the table.

If I set the colspan=2 for the first row then for the remaining rows it shows equal width. (It is not taking the width I specified.)

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

Is there anyway to set the specified column width for the remaining rows?


Solution

  • This is because fixed table layout is driven by first row OR column definition - try this

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