【问题标题】:Add Scrollbar on Bootstrap table grid under col 12 div在 col 12 div 下的 Bootstrap 表格网格上添加滚动条
【发布时间】:2019-03-17 18:32:59
【问题描述】:

在下面的网格中,我如何添加滚动条。 它只是使用 bootstrap col 12 div 下的 bootstrap table。

我尝试过使用以下 css,但它不应用滚动条,它只是弄乱了列。

divgrid.horizontal {
  width: 100%;
  height: 400px;
  overflow: auto;
}

.table {
  display: table;
  table-layout: fixed;
  width: 100%;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
  <div class="col-md-12" id="divgrid">
    <table class="table table-striped table-bordered">
      <thead class="ui-widget-header">
        <tr>
          <th v-for="header in columns()">
            {{header.displayName }}
          </th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(row,index) in datasourc">
          <td v-for="column in columns" class="wrap-break-word" v-show="column.isVisible">
            <span v-html="row[column.name]"></span>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

【问题讨论】:

    标签: html css vue.js bootstrap-4 styles


    【解决方案1】:

    将您的&lt;table&gt; 包装成&lt;div class="table-responsive"&gt;

    如果您只是将该类放在#divgrid 上,它可能会起作用。如果没有,请使用the docs 中指定的包装器。

    注意:这也适用于v3

    【讨论】:

    • 我现在可以看到滚动条了,但是所有的列标题都被弄乱了并且重叠了。显示了滚动条,但大多数列都适合屏幕,因此看起来所有列都重叠了。
    • 如果没有合适的minimal reproducible example,我帮不了你。您需要使用页面的实际 html 标记输出(源代码)更新问题中的代码 - 您可以通过在上下文菜单中选择“查看页面源代码”来获取它。
    猜你喜欢
    • 2016-12-12
    • 2021-10-22
    • 2014-03-13
    • 2019-10-02
    • 1970-01-01
    • 2015-06-03
    • 2017-02-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多