【问题标题】:how to change the color of md-input-container placeholder when focus?焦点时如何更改 md-input-container 占位符的颜色?
【发布时间】:2018-10-01 21:33:03
【问题描述】:

我正在使用 Angular 4,并且我有一个带有占位符的 md-input-container。当我在输入中键入内容时,占位符显示为标签。在这种情况下如何更改占位符的颜色?

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

【问题讨论】:

    标签: css angular input placeholder


    【解决方案1】:

    我通常使用 mat-form-field 作为 input 字段的包装器。

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

    现在您可以将以下代码添加到您的 CSS:

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

    请记住,如果您想更改一般的调色板,您应该考虑使用主题:https://material.angular.io/guide/theming

    【讨论】:

    • 但它在 Angular 4 中不起作用!如果我有一个 md-input-container 怎么办?
    • @fariba.j mhm,我找不到 angular 4 材料文档。你能创建一个 plunkr - 然后我将编辑代码。或者基本上只是调试标签并查找添加到容器上的focus 类。也许是
    猜你喜欢
    • 2017-05-03
    • 2012-10-22
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    • 2019-05-11
    • 2016-01-22
    • 2019-10-09
    • 1970-01-01
    相关资源
    最近更新 更多