Here's some table html-code, where the header-widths fit to their contents:
.my-table {
border: 1px solid;
border-spacing: 0;
table-layout: fixed;
border-collapse: separate;
box-sizing: border-box;
}
.my-table thead th {
border-bottom: 1px solid ;
border-right: solid 1px;
}
.my-table tbody td {
border-top: none;
border-left: none;
border-bottom: 1px dotted;
border-right: 1px solid;
}
<table class="my-table">
<thead>
<tr>
<th>
<div>
ID
</div>
</th>
<th>
<div>
Name
</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>1245</td>
<td>Michael Knight</td>
</tr>
<tr>
<td>1247</td>
<td>Devon Miles</td>
</tr>
</tbody>
</table>
Now I want to add text-inputs below the headers, but the input should not increase the header-widths. Does anyone know how to achieve this?
.my-table {
border: 1px solid;
border-spacing: 0;
table-layout: fixed;
border-collapse: separate;
box-sizing: border-box;
}
.my-table thead th {
border-bottom: 1px solid ;
border-right: solid 1px;
}
.my-table tbody td {
border-top: none;
border-left: none;
border-bottom: 1px dotted;
border-right: 1px solid;
}
<table class="my-table">
<thead>
<tr>
<th>
<div>
ID
</div>
<div>
<input type="text">
</div>
</th>
<th>
<div>
Name
</div>
<div>
<input type="text">
</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>1245</td>
<td>Michael Knight</td>
</tr>
<tr>
<td>1247</td>
<td>Devon Miles</td>
</tr>
</tbody>
</table>
Thanks!