如何为占位符的颜色设置样式?没有关于堆栈溢出发布的解决方案对我有用。
<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>
我尝试使用:
::ng-deep input.mat-input-element {
color: #ff884d;
caret-color: #ff884d;
}
所有css样式均被覆盖,但颜色相同。
::ng-deep .mat-form-field-placeholder{
color:red;
}
::placeholder
选择器更改占位符样式:::ng-deep input.mat-input-element::placeholder {
color: #ff884d;
caret-color: #ff884d;
}