Angular 10 - 删除垫子上的背景颜色-select
Angular 10 - Remove background color on mat-select
请看图片:
基本上,我想 change/remove 这个 mat-option 元素的背景颜色(灰色)。我还尝试使用浏览器检查器来查找具有背景色线的 class,但我什么也找不到。
有什么想法吗?
你可以试试:
.mat-form-field-appearance-fill .mat-form-field-flex {
background-color: red;
}
这对我有用。
您需要:
- 已弃用 ng-deep
- 关闭组件视图封装
- 使用全局样式
::ng-deep .mat-form-field-appearance-fill .mat-form-field-flex {
background-color: #fff;
}
只需输入您的 css 风格:
::ng-deep
.mat-form-field-type-mat-select:not(.mat-form-field-disabled)
.mat-form-field-flex {
background-color: transparent !important;
}
这里有一个演示:https://stackblitz.com/edit/angular-pj5rjj-hnmy6q?file=app%2Fsidenav-position-example.css
请看图片:
基本上,我想 change/remove 这个 mat-option 元素的背景颜色(灰色)。我还尝试使用浏览器检查器来查找具有背景色线的 class,但我什么也找不到。
有什么想法吗?
你可以试试:
.mat-form-field-appearance-fill .mat-form-field-flex {
background-color: red;
}
这对我有用。
您需要:
- 已弃用 ng-deep
- 关闭组件视图封装
- 使用全局样式
::ng-deep .mat-form-field-appearance-fill .mat-form-field-flex {
background-color: #fff;
}
只需输入您的 css 风格:
::ng-deep
.mat-form-field-type-mat-select:not(.mat-form-field-disabled)
.mat-form-field-flex {
background-color: transparent !important;
}
这里有一个演示:https://stackblitz.com/edit/angular-pj5rjj-hnmy6q?file=app%2Fsidenav-position-example.css