【发布时间】:2020-05-03 06:27:11
【问题描述】:
我有一个在mat-form-field 中输入的表单。它包含占位符,但我不知道如何设置占位符文本颜色。
当我之前没有关注输入时,占位符颜色为灰色:
当输入获得焦点时,它会变成紫色:
当输入失去焦点然后变成红色:
我的要求是换紫色的。我试过这个解决方案: https://css-tricks.com/almanac/selectors/p/placeholder/ 但它对我不起作用。
有什么想法吗?
更新:
这是被检查的输入:
<input _ngcontent-bqk-c14="" class="inputSearch input-textstyle mat-input-element mat-form-field-autofill-control cdk-text-field-autofill-monitored ng-pristine ng-invalid ng-touched" formcontrolname="description" matinput="" type="text" ng-reflect-autocomplete="[object Object]" ng-reflect-name="description" ng-reflect-placeholder=" Buscar" ng-reflect-type="text" autocomplete="off" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-haspopup="true" id="mat-input-1" placeholder=" Buscar" aria-invalid="true" aria-required="false">
提前致谢!
【问题讨论】:
-
您必须将
:placeholder与:foucs和:active一起使用 -
它没有用。我用过:input::placeholder:focus:active
标签: angular placeholder mat-form-field