我希望表格在滚动时粘住标题行,如何做到这一点?
我将不胜感激你的回答。
要在 ngx datatable 中使标头粘性,只需转到 node_modules/@swimlane/ngx-datatable/themes/bootstrap.scss
在 bootstrap.scss 中,将代码更新为此
.ngx-datatable.bootstrap {
box-shadow: none;
font-size: 13px;
.datatable-header {
height: unset !important;
position: sticky;
z-index: 2;
top: 0;
opacity: 100;
.datatable-header-cell {
vertical-align: bottom;
padding: 0.75rem;
background: #383a3e;
color: white;
border-bottom: 1px solid #d1d4d7;
.datatable-header-cell-label {
line-height: 24px;
}
}
}
保存文件并再次提供项目以查看更改。