【问题标题】:Html Table tbody not 100%Html Table tbody 不是 100%
【发布时间】:2017-11-18 04:34:55
【问题描述】:

我有一张桌子,但它不是 100%,它的 tbody 尺寸是:485x170px,

有人可以帮我把这个身体做到 100% 吗?

<thead> needs to be fixed as now.

我需要 scrool 并且 tbody 需要保持以下大小:height: calc(100vh - 513px); click to see the image

jsfiddle:https://jsfiddle.net/ab1Lsn0h/2/

css:

.staff table tbody {
  overflow-y: scroll;
  display: block;
  height: calc(100vh - 513px);
}

.staff tbody > tr {
  display: table;
  width: 100%;
}

html:

<div class="col-md-4">
  <div class="panel panel-default staff">
    <div class="panel-heading">test</div>
    <div class="panel-body">
      <table class="table table-striped">
        <thead>
          <tr>
            <th>Name</th>
            <th>Surname</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>name 1</td>
            <td>name 2</td>
          </tr>
          <tr>
            <td>name 1</td>
            <td>name 2</td>
          </tr>
          <tr>
            <td>name 1</td>
            <td>name 2</td>
          </tr>
          <tr>
            <td>name 1</td>
            <td>name 2</td>
          </tr>
          <tr>
            <td>name 1</td>
            <td>name 2</td>
          </tr>

        </tbody>
      </table>
      <div class="clearfix"></div>
    </div>
  </div>
</div>

【问题讨论】:

  • 你必须使用表格吗?我可以建议一种没有桌子的方法吗?
  • 不幸的是,我不得不使用表格,但你的方法是什么?

标签: html css twitter-bootstrap html-table


【解决方案1】:

您必须删除您的display: block;display: table;

你在表格中转换tr,这是错误的。

【讨论】:

  • 但我需要在我的身体中滚动了解吗?并且需要修复thead,所以这是我能做的唯一方法,
猜你喜欢
  • 2011-10-03
  • 2020-12-14
  • 2011-07-17
  • 2021-06-12
  • 2021-08-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-06
  • 1970-01-01
相关资源
最近更新 更多