相关疑难解决方法(0)

在bootstrap页面上居中表

我试图使用bootstrap中心表.

这是html:

<div class="container-fluid">
    <table id="total votes" class="table table-hover text-centered">
        <thead>
            <tr>
                <th>Total votes</th>
                <th> = </th>
                <th>Voter A</th>
                <th> + </th>
                <th>Voter B</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>{{ total_votes }}</td>
                <td> = </td>
                <td>{{ total_voter_a }}</td>
                <td> + </td>
                <td>{{ total_voter_b }}</td>
            </tr>
        </tbody>    
    </table>
</div>
Run Code Online (Sandbox Code Playgroud)

但是,无论我如何调整css,桌子仍然与左边对齐.我确定我错过了一些简单的事情.我还以为container-fluid会让这个表跨越整个页面.

这是css:

.table th {
    text-align: center;
}

.table {
    border-radius: 5px;
    width: 50%;
    float: none;
}
Run Code Online (Sandbox Code Playgroud)

html css twitter-bootstrap

12
推荐指数
2
解决办法
6万
查看次数

100% 宽度的中心引导表?

https://jsfiddle.net/t4ura97t/

<table class="table table-striped table-hover table-responsive">
  <thead>
    <th scope="col">column1</th>
    <th scope="col">column2</th>
    <th scope="col">column3</th>
  </thead>
  <tbody>
    <tr>
      <td>item1</td>
      <td>item2</td>
      <td>item3</td>
    </tr>
    <tr>
      <td>item1</td>
      <td>item2</td>
      <td>item3</td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

是否可以在不为表格提供 100% 以外的宽度的情况下将表格居中?我为此找到的大多数答案都使表格的宽度小于 100%。这不是很好,因为如果显示足够大,那么当您将元素居中时,表格似乎仍然没有居中。

css bootstrap-4

3
推荐指数
1
解决办法
9492
查看次数

标签 统计

css ×2

bootstrap-4 ×1

html ×1

twitter-bootstrap ×1