而不是使用
::ng-deep
将组件的ViewEncapsulation设置为none:
import {Component, ViewEncapsulation} from '@angular/core';
@Component({
selector: 'tab-group-stretched-example',
templateUrl: 'tab-group-stretched-example.html',
styleUrls: ['tab-group-stretched-example.css'],
encapsulation: ViewEncapsulation.None
})
export class TabGroupStretchedExample {}
然后使用以下CSS(我不得不使用另一个箭头,因为您在stackblitz中使用了本地引用):
.example-stretched-tabs {
max-width: 800px;
}
.mat-tab-list .mat-tab-labels .mat-tab-label-active {
color:#0f2241;
background-color: lightblue;
opacity: 1;
}
.mat-tab-group.mat-primary .mat-ink-bar {
background: none;
content: url('https://image.flaticon.com/icons/svg/60/60995.svg');
height: 10px;
}
这就是你想要的:
stackblitz