I've got a table like the one pictured above, which uses both colspan and rowspan. I want to fix all the column widths. I can do the first and last (No and Remark), and I can set the width of Types. How can I specify the widths of A, B and C?
I've tried giving cells A, B and C CSS classes and setting individual widths but this does not have any effect. The widths are always controlled by any content in the cells below.
table {
border-collapse:collapse;
table-layout:fixed;
width:100%;
}
th, td {
border:solid 1px #000;
padding:.5em;
}
.no {
width:10%;
}
.type {
width:50%;
}
.remark {
width:40%;
}
/* these don't work */
.type-a {
width:10%;
}
.type-b {
width:15%;
}
.type-c {
width:25%;
}
<table>
<thead>
<tr>
<th rowspan="2" class="no">No</th>
<th colspan="3" class="type">Type</th>
<th rowspan="2" class="remark">Remark</th>
</tr>
<tr>
<th class="type-a">A</th>
<th class="type-b">B</th>
<th class="type-c">C</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
Is it possible without resorting to placing fixed width divs inside the cells?