Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 角度10-删除mat select上的背景色_Css_Angular_Angular Material_Background Color - Fatal编程技术网

Css 角度10-删除mat select上的背景色

Css 角度10-删除mat select上的背景色,css,angular,angular-material,background-color,Css,Angular,Angular Material,Background Color,只需看一下图片: 基本上,我想更改/删除这个mat选项元素的背景色(灰色)。我还尝试使用浏览器检查器来查找具有背景色线的类,但什么也找不到 有什么想法吗?你可以试试: .mat-form-field-appearance-fill .mat-form-field-flex { background-color: red; } 这对我来说是个好办法。您需要: 不推荐的深度 关闭组件视图封装 使用全局样式 只需输入您的css样式: ::ng-deep .mat-form-field-t

只需看一下图片:

基本上,我想更改/删除这个mat选项元素的背景色(灰色)。我还尝试使用浏览器检查器来查找具有背景色线的类,但什么也找不到

有什么想法吗?

你可以试试:

.mat-form-field-appearance-fill .mat-form-field-flex {
   background-color: red;
}
这对我来说是个好办法。

您需要:

  • 不推荐的深度
  • 关闭组件视图封装
  • 使用全局样式

  • 只需输入您的css样式:

    ::ng-deep
      .mat-form-field-type-mat-select:not(.mat-form-field-disabled)
      .mat-form-field-flex {
      background-color: transparent !important;
    }
    

    这里是一个演示:

    您是对的,但是如果没有弃用的“ng deep”,它将无法在单个组件上工作,谢谢您。
    ng deep
    :它被标记为弃用:。
    ::ng-deep
      .mat-form-field-type-mat-select:not(.mat-form-field-disabled)
      .mat-form-field-flex {
      background-color: transparent !important;
    }