如何为 bootstrap table 设置特定宽度

How to set specific width for bootstrap table

我的html

<div class="container">
    <div class="row">
        <div>
            <table class="table table-bordered table-striped" width="600">
                <tr>
                    <td>User Count</td>
                    <td>@Model.UserCount</td>
                </tr>
            </table>
        </div>
    </div>
</div>

width="600" 被忽略。我在某处读到这是因为 table 100% 填满了容器。但是如何覆盖它并为 table 设置特定宽度?

使用style="width:600px"而不是width=600。 或者您可以按照 sheet:

的样式进行操作
.table {width:600px;}

请尝试以下,它对我有用:

.table
{
  width: 400px;
  border: 1px solid black;
}
<div class="container">
    <div class="row">
        <div>
            <table class="table table-bordered table-striped">
                <tr>
                    <td>User Count</td>
                    <td>@Model.UserCount</td>
                </tr>
            </table>
        </div>
    </div>
</div>