css - 如何在 CSS3 中更改 mat-checkbox 背景颜色? Angular 6

标签 css angular-material angular6

我需要用 mat-ripple use class="matCheckboxClass"改变背景

HTML:

<mat-checkbox class="matCheckboxClass"></mat-checkbox>

CSS3:

.matCheckboxClass .mat-checkbox-checked
.mat-accent.mat-checkbox-background, .mat-checkbox-indeterminate.mat-accent 
.mat-checkbox-background {
background-color: rgb(27, 142, 241) !important;
}

.matCheckboxClass .mat-ripple-element  {
 background: rgba(27, 142, 241, .4) !important;
 }

注意:::ng-deep 将更改所有 mat-checkbox 我需要更改特定的 mat-checkbox。

最佳答案

you can try this:

:host /deep/{
    .matCheckboxClass .mat-checkbox-checked
    .mat-accent.mat-checkbox-background, .mat-checkbox-indeterminate.mat-accent 
    .mat-checkbox-background {
    background-color: rgb(27, 142, 241) !important;
}

 .matCheckboxClass .mat-ripple-element  {
     background: rgba(27, 142, 241, .4) !important;
  }
}

关于css - 如何在 CSS3 中更改 mat-checkbox 背景颜色? Angular 6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52400352/

相关文章:

css - Wro4j:从 LESS 文件生成 CSS 文件

javascript - 是什么阻止我在 ng-grid 中选择内容?

html - 第一个单元格比其余单元格宽的表格

css - Angular Material如何对齐布局中心

javascript - 在 Angular 6 和 Asp Core 中显示带有 Blob 的图像

angular - 响应式(Reactive)表单自定义验证器不显示 Angular6 中的错误

javascript - 如何删除 dojo dijit 布局选项卡上的选择突出显示 css

带树的 Angular 形 Material 表

angular - 选择更改后让 MatSelect 保持打开状态

angular - 错误 NG2003 : No suitable injection token for parameter 'id' of class