css - 使用 Angular 7+ 和 Angular Material 更改占位符颜色?

标签 css angular angular-material

我希望使用 Angular 7+ 和 Angular Material 更改输入字段上占位符文本的颜色。

查看我尝试使用::ng-deep 和 mat-placeholder 的类似问题。我使用 mat-placeholder 让它工作,但是这将在 Angular Material 的 future 版本中被删除。

<form class="example-form">
  <mat-form-field class="example-full-width">
    <input matInput placeholder="Favorite food" value="Sushi">
  </mat-form-field>
</form>

更改 matInput 占位符文本的颜色。

最佳答案

<mat-form-field>
<input matInput type="text">
<mat-placeholder class="placeholder">Email</mat-placeholder>
</mat-form-field>

    .mat-form-field-underline {
    /*change color of underline*/
    background-color: #dce2f4 !important;
    } 

    .mat-form-field-ripple {
    /*change color of underline when focused*/
    background-color: #2e2f36 !important;
    } 
    .placeholder {
      color:  #dce2f4 ;

    }

关于css - 使用 Angular 7+ 和 Angular Material 更改占位符颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56935382/

相关文章:

typescript - 将 Angular 2 双向数据绑定(bind)与 Polymer 结合使用

angular - bypassSecurityTrustHtml 在使用 [innerHtml] 显示 html 时禁用 anchor 标记

javascript - 如何禁用 Angular Material Stepper 中的步骤?

angular - 在 Angular Material 中使用两种不同的字体

java - 无法将 css 链接到 jsp(Spring mvc)

javascript - Angular karma Jasmine 错误 : Illegal state: Could not load the summary for directive

html - css3 显示 : grid; or grid-column-start: isn't working

angular-material - 使标签标签在 Material 设计中拉伸(stretch)到全宽以实现角度

html - 使用 bootstrap 在悬停时边框到 div 的边缘

javascript - 在 mouseenter 上,如果复选框被选中,则执行 X,否则执行 Y