简体   繁体   English

焦点时如何更改md-input-container占位符的颜色?

[英]how to change the color of md-input-container placeholder when focus?

I'm using angular 4 and I have an md-input-container that has a placeholder. 我正在使用angular 4,并且有一个带有占位符的md-input-container。 when I type something in the input, the placeholder is shown as a label. 当我在输入中键入内容时,占位符显示为标签。 how can I change the color of the placeholder in this situation? 在这种情况下如何更改占位符的颜色?

 <md-input-container class="mb-1 data_font">
   <input mdInput placeholder="Full name">
 </md-input-container>

I'm usally working with mat-form-field as a wrapper for the input field. 我通常将mat-form-field用作input字段的包装。

<mat-form-field class="mb-1 data_font">
  <input mdInput placeholder="Full name">
</mat-form-field>

Now you can add the following code to your CSS: 现在,您可以将以下代码添加到CSS中:

.mat-focused .mat-form-field-label {
  color: red;
}

Keep in mind, if you want to change your color palette in general you should consider using a theme: https://material.angular.io/guide/theming 请记住,如果要总体上更改调色板,则应考虑使用以下主题: https : //material.angular.io/guide/theming

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

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