设置固定列宽不适用于Bootstrap 3

时间:2014-09-14 12:41:28

标签: html css twitter-bootstrap twitter-bootstrap-3 html-table

我有一个使用HTML和Bootstrap 3创建的表,如下例所示。

即使我通过colgroup中的width属性设置了固定的列宽,也没有应用,我在这里根本无法设置列宽。

有人可以告诉我在使用Bootstrap 3时是否需要以不同的方式进行操作或者我在这里缺少其他东西吗?
在这种情况下,我想将特定列(此处为第3列)的列宽设置为70px。

示例表

<table class="table table-condensed table-responsive tableDT">
    <colgroup>
        <col />
        <col />
        <col width="70px" />
    </colgroup>
    <thead>
        <tr>
            <th>Tag</th>
            <th>No. of Items</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Some text</td>
            <td>Some number</td>
            <td><button type='button' class='btn btn-primary btn-xs'>View</button></td>
        </tr>
    </tbody>
</table>

1 个答案:

答案 0 :(得分:1)

您不使用'px'。你只需要width="70" 你可以用css以及:

来做

colgroup col:last-child{ width: 70px; }