【问题标题】:Angular Material 2 target elements in CSSCSS中的Angular Material 2目标元素
【发布时间】:2018-06-18 19:16:56
【问题描述】:

我使用 Angular Material 使 UI 更“谷歌风格”,但我想在某些时候操作默认 CSS。例如,这是我的标记/角度材料代码:

   <mat-tab-group>
  <mat-tab label="Experience">
        <div *ngFor="let item of experienceItems"> 
          <mat-card>
             <mat-card-header>
             <mat-card-title> {{item?.startDate}} - {{item?.endDate}} <span class="card-company">{{item?.company}} - {{item?.location}}</span></mat-card-title>
              <mat-card-subtitle>{{item?.jobTitle}}</mat-card-subtitle>
            </mat-card-header>
            <mat-card-content>
              <i class="fa fa-keyboard-o" aria-hidden="true"></i>{{item?.description}}
            </mat-card-content> 
          </mat-card> 
          <br/>
       </div>
  </mat-tab>
</mat-tab-group> 

我想替换标签中的一些默认值,例如:

.mat-tab-label{
    text-transform: uppercase;
    color: white;
    /*remove min-width*/
}

但它不起作用..

我的 CSS 位于:

@Component({
  selector: 'app-about',
  templateUrl: './template/app-about.html',
  styleUrls: ['./css/style.css']
})

任何应用于其他元素的 CSS 都可以很好地工作。对于 Angular Material 元素,它不会。

欢迎任何帮助!

【问题讨论】:

标签: css angular angular-material


【解决方案1】:

对于角材料,您需要使用::ng-deep

在你的css中做:

::ng-deep .mat-tab-label {
 text-transform: uppercase;
    color: white;
    /*remove min-width*/
}

【讨论】:

  • 不客气,请选择我的最佳答案,让我们收工吧:)
  • 还有 8 分钟..!
猜你喜欢
  • 2018-03-13
  • 1970-01-01
  • 2018-02-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-23
  • 2016-04-07
  • 2019-07-27
相关资源
最近更新 更多