【问题标题】:Change Angular mat chip default colors更改角垫芯片默认颜色
【发布时间】:2020-07-04 03:46:42
【问题描述】:

我是 Angular 的新手,我正在尝试使用全局 CSS 文件更改垫板默认颜色,但由于某种原因,它不允许我更改默认芯片颜色和内部文本颜色。

Homepage.component HTML

      <mat-chip-list>
        <mat-chip>Tag1</mat-chip>
      </mat-chip-list>

全局 CSS

.mat-chip{
    background-color:mat-color($accent);
    color: mat-contrast($positive,50);
}

This is what it look like inside mat-card

【问题讨论】:

  • 您想用mat-color($accent)mat-contrast($positive,50) 实现什么目标?
  • 嗨 Michale,我的高级开发人员创建了另一个名为 styles-theme.scss 的全局 CSS 主题文件,我指的是该文件中的颜色。他不希望我对每个元素都进行硬编码,所以我正在尝试使用该主题文件更改芯片颜色。我可以更改 mat-card 的颜色,但我不确定为什么它不允许我更改 mat-chip 的颜色。
  • 那么我们可能需要看看这些函数。你也在使用 SCSS。请停止引用 CSS。它们是不同的。
  • 感谢您尝试帮助我,但 Thierry Falvo 的评论已经解决了我的问题。还是谢谢你。

标签: css angular angular-material tags styles


【解决方案1】:

你可以使用!important操作符,如下:

.mat-chip{
  background-color: mat-color($accent) !important;
  color: mat-contrast($positive,50) !important;
}

【讨论】:

猜你喜欢
  • 2021-10-21
  • 1970-01-01
  • 2020-08-03
  • 2019-05-10
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 2021-01-16
  • 1970-01-01
相关资源
最近更新 更多