【问题标题】:Bootstrap 4 .table-responsive class won't take 100% widthBootstrap 4 .table-responsive 类不会占用 100% 的宽度
【发布时间】:2018-04-19 23:05:23
【问题描述】:

我得到了 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>

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

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

更新:

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

其实it's a issue on Bootstrap 4,所以这个问题的-2声望是无效的。谢谢。

【问题讨论】:

  • 请提供您的代码。
  • 您需要发布更多代码,以便我们查看其他可能影响表格的因素。
  • 晚安,伙计们,刚吃完午饭回来(我的问题已经得到-2)。对我不起作用的示例:bootply.com/yQCAW8tiN0 在 bootply 上它工作正常,但在我的应用程序上看起来像这样:prntscr.com/h7duxs 完全相同的代码,我要研究更多,在 stackoverflow 上得到这个关于同一主题的问题: stackoverflow.com/questions/41747667/…还有@Pete你不用这样回答,可能会让人不敢问,问是本站的主要目的。
  • 您能否指出我的问题@Pete 不接受的地方在哪里?

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


【解决方案1】:

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

编辑:通过添加类 table-responsive 作为 tablehere is the ship list for the fixthe issue that reported the bug 的父 div 来修复它。

<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 sn-p 纠正了它,你只需要对人更有礼貌;)谢谢
  • @Pete,你能看看我的问题吗?已经一年了,但由于投票赞成,我再次来到这里。
  • @Pete 删除了他所有的 cmets,他争论了很多,让我对在 SO 提出问题感到难过,现在正在他的个人资料 (stackoverflow.com/users/1790982/pete) 上宣传一个更受欢迎的 SO,恭喜,改变了为了更好。
猜你喜欢
  • 2017-06-04
  • 1970-01-01
  • 1970-01-01
  • 2015-04-27
  • 1970-01-01
  • 2017-09-30
  • 2021-04-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多