html - 语义 UI - 滚动 tbody 时保持广告可见

标签 html css semantic-ui

我正在尝试弄清楚如何在滚动时保持表头可见。语义ui中是否有为此设置?还是我只需要使用非语义 UI 解决方案?

您需要查看“整页”才能正确查看表格。

<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.0/semantic.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.0/semantic.css" rel="stylesheet" />

<div style="height:200px;overflow:auto">
  <table class="ui small celled striped table" sytle="width:100%">
    <thead>
      <tr>
        <th>Date</th>
        <th>Status</th>
        <th>Facility Name</th>
        <th>Phone</th>
      </tr>
    </thead>
    <tbody data-bind="foreach:FollowupEntries">
      <tr>
        <td>Date</td>
        <td>Status</td>
        <td>Facility Name</td>
        <td>Phone</td>
      </tr>
      <tr>
        <td>Date</td>
        <td>Status</td>
        <td>Facility Name</td>
        <td>Phone</td>
      </tr>
      <tr>
        <td>Date</td>
        <td>Status</td>
        <td>Facility Name</td>
        <td>Phone</td>
      </tr>
      <tr>
        <td>Date</td>
        <td>Status</td>
        <td>Facility Name</td>
        <td>Phone</td>
      </tr>
      <tr>
        <td>Date</td>
        <td>Status</td>
        <td>Facility Name</td>
        <td>Phone</td>
      </tr>
      <tr>
        <td>Date</td>
        <td>Status</td>
        <td>Facility Name</td>
        <td>Phone</td>
      </tr>
      <tr>
        <td>Date</td>
        <td>Status</td>
        <td>Facility Name</td>
        <td>Phone</td>
      </tr>
      <tr>
        <td>Date</td>
        <td>Status</td>
        <td>Facility Name</td>
        <td>Phone</td>
      </tr>
    </tbody>
  </table>
</div>

最佳答案

我用position: sticky解决了这个问题,像这样:

.ui.table thead tr:first-child > th {
     position: sticky !important;
     top: 0;
     z-index: 2;
}

关于html - 语义 UI - 滚动 tbody 时保持广告可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29906134/

相关文章:

php - url 重写在本地工作但不在服务器上工作

php - HTML/PHP post 方法

html - 如何解决CSS文件之间的冲突

html - CSS-Grid:如何在不缩小元素本身的情况下将内容居中?

css - 为什么 css 样式不适用于模式?

css - 如何使用语义 UI 正确对齐按钮

html - 如何在同一页面中为 "visited" anchor 设置不同的颜色?

jquery - 如何创建具有特殊行为的元素

html - 位置固定的元素离开页面/窗口 - 如何在某个时候停止?

gulp - 如何在语义 UI 中自定义容器宽度