简体   繁体   English

为 angular mat-tab 覆盖 css

[英]Overwriting css for angular mat-tab

I wanted to change mat label color for a mat-tab.我想更改垫子标签的垫子 label 颜色。 css that I've added is:我添加的 css 是:

.mat-tab-label {
  min-width: 25px !important;
  padding: 5px;
  background-color: transparent;
  color: white;
  opacity: 1 !important;
  font-weight: 700;
}

It is changing color for tab.它正在改变标签的颜色。 But, it is changing color for all mat-tabs in whole application.但是,它正在改变整个应用程序中所有 mat-tabs 的颜色。 How can I change for a particular tab alone.如何单独更改特定选项卡。

You can use the component tag label,您可以使用组件标签 label,

 app-component-name .mat-tab-label {
    min-width: 25px !important;
    padding: 5px;
    background-color: transparent;
    color: white;
    opacity: 1 !important;
    font-weight: 700;
}

Or add a class to the tab或将 class 添加到选项卡

You have to override class style in style.css or style.scss您必须在 style.css 或 style.scss 中覆盖 class 样式

.mat-tab-label {
  min-width: 25px !important;
  padding: 10px;
  background-color: transparent;
  color: white;
  opacity: 1 !important;
  font-weight: 700;
}

Stackblitz: https://stackblitz.com/edit/angular-mat-tab-active-89vnui Stackblitz: https://stackblitz.com/edit/angular-mat-tab-active-89vnui

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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