Bootstrap 4 .table-responsive类不会占用100%的宽度

时间:2017-11-07 13:56:45

标签: html twitter-bootstrap bootstrap-4 twitter-bootstrap-4

我有2张相同HTML的表,并且都声明为:



<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
  <div class="row">
    <div class="col-12 col-md-6">
      <div class="card">
        <div class="card-body">
          <table class="table table-sm table-hover table-responsive">
              <thead>
                  <tr>
                      <th>Item 01</th>
                      <th>Item 02</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <td>Item 01</td>
                      <td>Item 02</td>
                  </tr>
              </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;

这就是我在屏幕上看到的内容:

Check this picture

使用相同HTML声明的第二个和连续表格不会在theadtbody上获得100%的宽度... 这有什么不对?

更新:

我的第一张桌子因为最后一行的内容而工作,它足够长,足以让它在我的卡片上100%合适。

实际上it's a issue on Bootstrap 4,因此这个问题的-2声誉无效。感谢。

1 个答案:

答案 0 :(得分:2)

发现它在Bootstrap V4上存在问题,您可以在此issue中看到,我的第一个表格不起作用,它只是最后一行的内容足够长为了满足桌面宽度,所以它看起来很有效。

编辑:通过添加表响应类作为here is the ship list for the fixthe issue that reported the bug的父div来解决此问题。< / p>

&#13;
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
  <div class="row">
    <div class="col-12 col-md-6">
      <div class="card">
        <div class="card-body">
          <div class="table-responsive">  
            <table class="table table-sm table-hover">
                <thead>
                    <tr>
                        <th>Item 01</th>
                        <th>Item 02</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Item 01</td>
                        <td>Item 02</td>
                    </tr>
                </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;