我有问题,这是我的代码:
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th colspan="9" style="text-align: center">Main Header</th>
</tr>
</thead>
<tr>
<th>checkbox</th>
<th>columna 1</th>
<th>columna 2</th>
<th>columna 3</th>
<th>columna 4</th>
<th>columna 5</th>
<th>columna 6</th>
<th>columna 7</th>
<th>columna 8</th>
<th>columna 9</th>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>coso 1</td>
<td>coso 2</td>
<td>coso 3</td>
<td>coso 4</td>
<td>coso 5</td>
<td>coso 6</td>
<td>coso 7</td>
<td>coso 8</td>
<td>coso 9</td>
</tr>
<tr>
<th></th>
<th>columna 1</th>
<th>columna 2</th>
<th>columna 3</th>
<th>columna 4</th>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>coso 1</td>
<td>coso 2</td>
<td>coso 3</td>
<td>coso 4</td>
</tr>
</table>
我正在使用 Bootstrap,问题是第四行和第五行比其他行短,我想做的是那些 td 填充所有宽度而没有 colspan,因为这些行来自服务器而我不不知道有多少,我只知道最大的列数是 9,我要做的是填充所有宽度,以便在较短的行的右侧没有空白。
最佳答案
我知道你想避免使用 colspan,到目前为止我还没有找到方法,但是让 colspan > max of columns that you could dynamically have, will do the trick, nothing will overflow.
关于css - 如何使 td 在没有 colspan 的情况下填充表格中的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50098868/