首页 > 解决方案 > 如何使 td 在没有 colspan 的情况下填充表格中的所有行

问题描述

我有一个问题,这是我的代码:

<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,我要做的是填充所有宽度,以便在较短的行的右侧没有空白。

标签: csshtmltwitter-bootstraphtml-table

解决方案


推荐阅读