angular - Angular如何在滚动时固定表头
问题描述
我在 Angular 中有一个表格,我想在滚动时修复它的标题,但我无法获得所需的结果。每次没有按应有的方式呈现另一个元素时。
我尝试将固定的 css 类应用到 THEAD 的 TR,但我无法得到想要的结果
链接到我的 stackblitz: https ://stackblitz.com/edit/angular-vpxuo1
解决方案
This worked with your stackblitz you provided
CSS:
.table-fixed {
width: 100%;
}
/*This will work on every browser but Chrome Browser*/
.table-fixed thead {
position: sticky;
position: -webkit-sticky;
top: 0;
}
/*This will work on every browser*/
.table-fixed thead th {
position: sticky;
position: -webkit-sticky;
top: 0;
}
Html:
<table id="tableSortExample" mdbTable class="z-depth-1 table-fixed">
<thead>
<tr>
<th aria-controls="tableSortExample" scope="col" class="blue-text pointer-hover" [mdbTableSort]="history"
[sortBy]="headElements[0]">
Type
<mdb-icon fas icon="sort"></mdb-icon>
</th>
Reference this link for more information: stackoverflow.com
推荐阅读
- angular - ChartJs 不能在没有错误的角度 4 中工作
- java - spring webclient 和 httpsurlconnection 请求 https 接口的一些区别
- php - Facebook SDK 返回错误:Stream 在 facebook SDK5 php CodeIgniter 3 中返回空响应
- c# - ASP.NET C# 从数据库中检索多个值并添加到会话中
- google-chrome - 浏览器从缓存中加载 JS 文件,而不是 CSS 文件
- jquery - 在 Jquery 中选择多个复选框
- html - 如何使幻灯片图像在不同的视口尺寸下按比例缩放?
- ios - 将单元格添加到可见的空 UITableView 以白色背景显示
- java - 如何在java中使用正则表达式在特定位置的文本中查找数字
- python - 为什么 matplotlib.pyplot.imsave() 和 matplotlib.pyplot.imshow() 图像质量不同?如何保证同样的质量?