如何更改matinput占位符的颜色?

问题描述 投票:0回答:1

如何为占位符的颜色设置样式?没有关于堆栈溢出发布的解决方案对我有用。

<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样式均被覆盖,但颜色相同。

css angular-material
1个回答
0
投票
尝试一下

::ng-deep .mat-form-field-placeholder{ color:red; }


0
投票
您可以使用CSS ::placeholder选择器更改占位符样式:

::ng-deep input.mat-input-element::placeholder { color: #ff884d; caret-color: #ff884d; }

© www.soinside.com 2019 - 2024. All rights reserved.