更新时间:2023-01-05 19:39:42
在您的组件中,设置 ViewEncapsulation 到None
,然后在您的component.css文件中添加样式.
In your component, set ViewEncapsulation to None
and add the styles in your component.css file.
打字稿代码的更改:
import {Component, ViewEncapsulation} from '@angular/core';
@Component({
....
encapsulation: ViewEncapsulation.None
})
组件CSS:
/* Styles for tab labels */
.mat-tab-label {
min-width: 25px !important;
padding: 5px;
background-color: transparent;
color: red;
font-weight: 700;
}
/* Styles for the active tab label */
.mat-tab-label.mat-tab-label-active {
min-width: 25px !important;
padding: 5px;
background-color: transparent;
color: red;
font-weight: 700;
}
/* Styles for the ink bar */
.mat-ink-bar {
background-color: green;
}