在 table 上自定义 CSS material 选项卡不起作用
Customizing CSS material tab on a table does not work
在我的 angular 5 应用程序中,我使用 Material API。
我有一个 table 有 2 个这样的标签:
<mat-tab-group>
<mat-tab>
<mat-table>
<!-- some stuff -->
</mat-table>
</mat-tab>
<mat-table>
<!-- some stuff -->
</mat-table>
</mat-tab>
</mat-tab-group>
我尝试自定义 <mat-tab>
组件的 css 但它不起作用,我一一尝试了所有这些:
.mat-tab-label-active {
color: rgb(255, 255, 255) !important;
background-color: red !important;
}
.mat-tab-nav-bar {
color: rgb(255, 255, 255) !important;
background-color: red !important;
}
.mat-tab-group {
color: rgb(255, 255, 255) !important;
background-color: rgba(19, 23, 63, 0.993) !important;
}
只有 .mat-tab-group
有效。我只想自定义选项卡单元格而不是整个选项卡组。有什么想法吗?
根据我的意见:使用垫子选项卡的 ng-template
属性 自定义它们。 Stackblitz
<mat-tab-group>
<mat-tab label="First">
<ng-template mat-tab-label>
<span class="customized-label">
This is a customized label
</span>
</ng-template>
</mat-tab>
<mat-tab label="Second"> Content 2 </mat-tab>
<mat-tab label="Third"> Content 3 </mat-tab>
</mat-tab-group>
.customized-label {
color: red;
font-weight: 700;
}
在我的 angular 5 应用程序中,我使用 Material API。
我有一个 table 有 2 个这样的标签:
<mat-tab-group>
<mat-tab>
<mat-table>
<!-- some stuff -->
</mat-table>
</mat-tab>
<mat-table>
<!-- some stuff -->
</mat-table>
</mat-tab>
</mat-tab-group>
我尝试自定义 <mat-tab>
组件的 css 但它不起作用,我一一尝试了所有这些:
.mat-tab-label-active {
color: rgb(255, 255, 255) !important;
background-color: red !important;
}
.mat-tab-nav-bar {
color: rgb(255, 255, 255) !important;
background-color: red !important;
}
.mat-tab-group {
color: rgb(255, 255, 255) !important;
background-color: rgba(19, 23, 63, 0.993) !important;
}
只有 .mat-tab-group
有效。我只想自定义选项卡单元格而不是整个选项卡组。有什么想法吗?
根据我的意见:使用垫子选项卡的 ng-template
属性 自定义它们。 Stackblitz
<mat-tab-group>
<mat-tab label="First">
<ng-template mat-tab-label>
<span class="customized-label">
This is a customized label
</span>
</ng-template>
</mat-tab>
<mat-tab label="Second"> Content 2 </mat-tab>
<mat-tab label="Third"> Content 3 </mat-tab>
</mat-tab-group>
.customized-label {
color: red;
font-weight: 700;
}