作者:lisen0001 | 来源:互联网 | 2023-02-03 18:46
1> Kirill Matro..:
position:sticky不适用于Chrome中的某些表元素(thead/tr).您可以将粘性移动到需要粘贴的tds/ths.像这样:
.table {
thead tr:nth-child(1) th{
background: white;
position: sticky;
top: 0;
z-index: 10;
}
}
这也行.
.table {
position: sticky;
top: 0;
z-index: 10;
}
您可以将标题移动到单独的布局.例如:
值得注意的是,如果表包含在`overflow:auto`或`overflow-x:auto`的元素中,这将不起作用.如果在bootstrap的`.table-responsive`类中包装表,就会发生这种情况.
如果列的宽度相同,则单独的布局选项才可用
2> Tomsgu..:
对于那些仍在寻找解决方案并且对已接受的解决方案不满意的人.
1)在元素上使用粘性顶级类.
2)有自己的班级
th.sticky-header {
position: sticky;
top: 0;
z-index: 10;
/*To not have transparent background.
background-color: white;*/
}
如果`thead`中有两个(或更多)标题行怎么办?