[英]How to apply custom styles for Tabs in Angular Material 6?
I am using two tab groups namely tab1 and tab2. 我正在使用两个选项卡组,即tab1和tab2。 This is my code:
这是我的代码:
<mat-tab-group class="tab1">
<mat-tab label="First"> Content 1 </mat-tab>
<mat-tab label="Second"> Content 2 </mat-tab>
<mat-tab label="Third"> Content 3 </mat-tab>
</mat-tab-group>
<mat-tab-group class="tab2">
<mat-tab label="Fourth"> Content 4 </mat-tab>
<mat-tab label="Fifth"> Content 5 </mat-tab>
<mat-tab label="Sixth"> Content 6 </mat-tab>
</mat-tab-group>
Now I need to apply custom CSS differently for both of the tabs (label, label-content, label-height, label-padding). 现在,我需要对两个选项卡(标签,标签内容,标签高度,标签填充)分别应用自定义CSS。 But it is not working.
但这是行不通的。 I even tried overriding it with
::ng-deep
, it is not applying. 我什至尝试用
::ng-deep
覆盖它,但没有应用。 Here's my CSS code: 这是我的CSS代码:
::ng-deep .tab1 > .mat-tab-label-content{
color: red !important;
padding: 10px;
margin: 10px;
}
I also tried giving this, but not working: 我也尝试给出这个,但是不起作用:
::ng-deep .tab1 .mat-tab-label-content{
color: red !important;
min-width: 0;
padding: 30px;
margin: 30px;
}
So please suggest me how to apply css for each tabs respectively. 因此,请建议我如何分别为每个标签应用CSS。
This code should do the trick: 这段代码可以解决这个问题:
.tab1 .mat-tab-label-content {
color: red;
}
See example: https://angular-ekc6jo.stackblitz.io/ 参见示例: https : //angular-ekc6jo.stackblitz.io/
Are you sure your CSS is loaded properly? 您确定CSS加载正确吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.