在我的 Angular 6 应用程序中使用时mat-table,我无法正确设置水平滚动的背景mat-header-row颜色mat-row。CSS 属性仅应用于屏幕的可见部分,一旦向右滚动,就不会分配颜色。
我的表中有大约 30 列,因此肯定需要水平滚动。
我的CSS如下:
.mat-toolbar {
font-size: 17px;
font-family: inherit;
background-color: indigo;
max-height: 12vh;
}
.mat-elevation-z8 {
padding: 0px;
}
.mat-table {
overflow: auto;
max-height: 68vh;
min-width: 100%;
}
.mat-header-row {
position: sticky;
top: -.5px;
z-index: 100;
background-color: gainsboro;
font-size: 12px;
min-height: 8vh;
color: #f5f5f5;
padding-top: 3px;
}
.mat-row:nth-child(even) {
background-color: floralwhite;
}
.mat-row:nth-child(odd) {
background-color: gainsboro;
}
.mat-row {
min-height: 8vh;
}
.no-results {
display: flex;
justify-content: center; …Run Code Online (Sandbox Code Playgroud)