css - 更改禁用材质填充输入的背景
问题描述
使用 Angular Material 我可以改变这个填充垫输入的背景:
<mat-form-field>
<mat-label>Tax-number</mat-label>
<input type="text" matInput [id]="'taxnumber'" [formControl]="controlContainer.control.controls['taxnumber']">
<mat-error>{{controlContainer.control.controls['taxnumber'].errors | bsErrorMessage}}</mat-error>
</mat-form-field>
我可以使用以下 css 更改背景:
.mat-form-field-appearance-fill
.mat-form-field-flex {
background: rgba(255, 255, 255, 1);
}
现在我想在禁用时更改控件的背景。我最好的猜测是
.mat-form-field-appearance-fill:disabled
.mat-form-field-flex:disabled {
background: rgba(255, 15, 15, 1);
}
但这不起作用。那么如何更改禁用的角度材质填充输入的背景呢?
我为这个问题创建了一个 stackblitz: https ://stackblitz.com/edit/angular-bcqsjo
解决方案
查看您的 stackblitz 链接,我刚刚打开了 chrome 开发工具并检查了禁用的字段。这是正在应用的css:
.mat-form-field-appearance-fill.mat-form-field-disabled .mat-form-field-flex {
background-color: rgba(0,0,0,.02);
}
所以父级上有一个附加类(mat-form-field-disabled)。您更新的代码将是:
.mat-form-field-appearance-fill.mat-form-field-disabled .mat-form-field-flex {
background: rgba(255, 255, 255, 1);
}
推荐阅读
- ruby - hash.merge with block to add up sub-hash keys?
- ios - Wrong NTP date response Swift 4
- javascript - 带有单页应用程序抛出错误的 Office Dialog API
- gitlab - 如何在 gitlabs 登录后设置应用程序代理?
- laravel - Laravel 5.7 在视图中重新格式化日期时间戳
- reactjs - how to pass prop into rowrender of react-virtualized
- gatsby - How do I make GraphQL wait for posts from a separate repo?
- excel - 保存宏在一台机器上工作,而不是在另一台机器上
- c# - 如何使 emf 文件 dpi 感知
- php - 为什么查询不会像在 phpmyadmin 中那样返回显示名称?