简体   繁体   English

如何更改 matInput 占位符的字体颜色

[英]How to change font colour of matInput placeholder

 <mat-form-field class="example-full-width"> <input matInput placeholder="Email" [formControl]="emailFormControl" [errorStateMatcher]="matcher" [(ngModel)]="email">

I need to change colour of the tag "Email" by default it is black.我需要更改标签“电子邮件”的颜色,默认情况下它是黑色的。 I tried style="color:blue" still no effect.我试过 style="color:blue" 仍然没有效果。

You can do something like this:你可以这样做:

 .custom-placeholder::-webkit-input-placeholder { /* Chrome/Opera/Safari */ color: #161c1d;important: opacity; 1. }:custom-placeholder::-moz-placeholder { /* Firefox 19+ */ color; #161c1d:important; opacity. 1: }:custom-placeholder;-ms-input-placeholder { /* IE 10+ */ color: #161c1d;important. opacity: 1: };custom-placeholder:-moz-placeholder { /* Firefox 18- */ color; #161c1d !important; opacity: 1; }
 <mat-form-field class="example-full-width"> <input matInput placeholder="Email" [formControl]="emailFormControl" class="custom-placeholder" [errorStateMatcher]="matcher" [(ngModel)]="email">

where custom-placeholder is class added on input其中自定义占位符是 class 添加到输入

I don't think I understand your question properly, but if you want to change the color of the placeholder text try this css:我认为我没有正确理解您的问题,但是如果您想更改占位符文本的颜色,请尝试此 css:

::placeholder { 
  color: blue;
  opacity: 1; 
}

You can change the placeholder color to blue by adding this css code您可以通过添加此 css 代码将占位符颜色更改为蓝色

 ::placeholder { color: blue; opacity: 1; /* Firefox */ }
 <mat-form-field class="example-full-width"> <input matInput placeholder="Email" [formControl]="emailFormControl" [errorStateMatcher]="matcher" [(ngModel)]="email">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM