//固定首列 左 第一列td和th都要绑定这个class
.fixedLeft1 {
outline: 1px solid #dcdfe6 ;
position: sticky !important;
z-index: 1 ;
left: 0 ;
background: white;
}
//固定第二列 左 因为首列宽为80px,所以left要80px 最后列td和th都要绑定这个class
.fixedLeft2 {
outline: 1px solid #dcdfe6 ;
position: sticky !important;
z-index: 1 ;
left: 80px ;
background: white;
}
//固定最后列(你也可以不是最后一列) 右 最后列td和th都要绑定这个class
.fixedRight{
outline: 1px solid #dcdfe6 ;
position: sticky!important;
z-index: 1;
right:0;
background: white;
}
//固定表头 记得z-index 要比上面的td,th大
thead{
position: sticky !important;
z-index: 2 ;
top: 0;
}
html原生css 固定列和表头 表格
于 2023-04-27 15:32:32 首次发布