css - 如何使 td 在没有 colspan 的情况下填充表格中的所有行

标签 css html twitter-bootstrap html-table

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

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

相关文章:

html - 在小屏幕上需要从右到左下方流动(右固定宽度,左可变宽度)

javascript - 在 bootstrap 多选下拉菜单上创建工具提示

javascript - 速度滚动动画 jQuery

html - 可以右键打开但是不能点击打开

javascript - 如何使用 jquery 将无序列表转换为 <select> 下拉列表?

android - 滚动时绝对定位的 div "lag behind"中的相对定位元素

javascript - 使用 jQuery 在悬停时显示菜单子(monad)元素

python - 如何使用 Django 在 Bootstrap 中每行显示 2 个 span6 的缩略图?

javascript - Bootstrap 介入 datatable css

html - 重要的!烦恼