简体   繁体   中英

How To Style Mat-Ink-Bar with Different Color for Each Mat-Tab In Angular Material?

I am trying to style each mat-tab with a different color at all time, whether the tab is active or not. I am able to style the mat-ink-bar for all tabs but I am having a hard time figuring this out for each tab. Please help.

 /* label style */.mat-tab-label{ background: green; color:white; } /* ink bar style */.mat-tab-group.mat-primary.mat-ink-bar{ background: yellow; height: 10px; } /* Trying to style the second mat-ink bar */.mat-tab-group.mat-primary >.USD.mat-ink-bar{ background: blue; height: 10px; }
 <mat-tab-group> <mat-tab class="USD" label="USD">USD</mat-tab> <mat-tab class="AUD" label="AUD">AUD</mat-tab> <mat-tab label="AED">AED</mat-tab> <mat-tab label="CAD">CAD</mat-tab> </mat-tab-group>

This might be a stupid answer, but have you tried just doing this?

  .USD{
  background: blue;
  height: 10px;
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM