html - 我在一个页面上有多个表格,我希望这些表格的标题是粘性的
问题描述
我在一个页面上有多个表格,我希望这些表格的标题是粘性的。
这是我的小提琴:JSFiddle
这是涉及 div 包装器和表头的 CSS:
.scroll {
overflow: auto;
max-height: 300px;
position: relative;
}
.headclass th{
position: sticky;
top: 0;
}
解决方案
您不能使用position: sticky;
on<thead>
和/或<tr>
element 但 on<th>
删除您已经创建的类:
.headclass th{
position: sticky;
top: 0;
}
相反,使用这个:
.headclass tr.bg-info th {
background: #17a2b8;
position: sticky;
top: 0;
}
推荐阅读
- .net - 如何在视觉工作室中列出符号?
- c - 当我声明这两个变量时,为什么我的程序会崩溃?
- javascript - 当您有多个标记时,更改单击的标记图标
- javascript - 在 ReactJS 中获取 PHP 文件的回显
- javascript - FAQ 手风琴显示/隐藏
- angular - 通过在 Angular 应用程序的浏览器中手动输入其 URL 导航到特定页面(而不是根页面)并避免错误 404 (IIS)
- java - ActionListener 没有用 JButton 点击替换所需的面板
- java - 无法插入到 SQLite 数据库
- c++ - NS3-如何在模拟运行期间修改点对点通道数据速率
- html - 边距不当