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

标签 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>

这是我在屏幕上看到的:

Check this picture

用相同 HTML 声明的第二个和连续的表在 theadtbody 上没有获得 100% 的宽度... 这里有什么问题?

更新:

由于最后一行的内容,我的第一个表格可以正常工作,它足够长以使其 100% 适合我的卡片 div。

实际上 it's a issue on Bootstrap 4 , 所以这个问题的-2 信誉是无效的。谢谢。

最佳答案

发现是Bootstrap V4的问题,可以看这个issue ,我的第一个表格不工作,它只是最后一行的内容足够长以填满表格宽度,所以它看起来像工作。

编辑:通过添加 table-responsive 类作为 table 的父 div 得到修复,here is the ship list for the fixthe issue that reported the bug .

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

关于html - Bootstrap 4 .table-responsive 类不会占用 100% 宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47159748/

相关文章:

css - 无法让列表项排队

javascript - 我可以从输入字段作为数据 URL 获取的最大文件大小是多少?

html - 限制 flexbox 元素的高度

javascript - 如何在没有模板的情况下添加 View ?

html - Bootstrap Carousel 图像过渡幻灯片不起作用

css - 下拉列表在单个 HTML 页面中工作但在 Angular 组件中不工作

jquery - data-parent 属性在崩溃 Bootstrap v4-alpha 上不起作用

jquery - Bootstrap 4.3.0 工具提示与 jQuery UI 1.12.1 冲突

html - Margin top 在 IE 6 中不起作用

html - 什么可能导致 Firefox 中出现此 HTML/CSS 呈现问题?