css - 如何更改 matinput 占位符的颜色?
问题描述
如何设置占位符的颜色?在堆栈溢出上发布的任何解决方案都不适合我。
::ng-deep input.mat-input-element {
color: #ff884d;
caret-color: #ff884d;
}
<form class="example-form">
<mat-form-field class="example-full-width">
<input [(ngModel)]="email" matInput placeholder="Email" [formControl]="emailFormControl">
<mat-error *ngIf="emailFormControl.hasError('email') && !emailFormControl.hasError('required')">
Please enter a valid email address
</mat-error>
<mat-error *ngIf="emailFormControl.hasError('required')">
Email is <strong>required</strong>
</mat-error>
</mat-form-field>
</form>
所有的css样式都被覆盖了,但是颜色是一样的。
解决方案
使用它来覆盖特定的组件输入占位符。
:host /deep/ mat-form-field-placeholder{
color: #ff884d;
}
如果要在全局范围内覆盖样式。然后使用您的全局样式表使用重要关键字覆盖
mat-form-field-placeholder{
color: #ff884d !important;
}
推荐阅读
- java - 如何使用浏览器访问安全的 Spring API?
- c# - C#:运行N个任务的正确方法,等待第一次成功(检查它),停止其他任务并尽快将结果返回给用户
- excel - 365 office运行时1004调试
- c# - 每两次调用一次事件点击
- reactjs - React - 使用新方法时如何更改以旧方式编写的代码?
- pdf - Mendeley 以前的 pdf 视图功能?
- linux - 期望 ssh reg_ex 用于远程提示
- apache-kafka - 将 Kafka 拆分为单独的主题或单个主题/多个分区
- javascript - 使用 $: 代替 const/var/let 时有什么行为
- android - 我无法显示来自 firebase 数据库的实际格式数据