簡體   English   中英

如何更改占位符顏色<input>它在里面<mat-form-field>從角材料?

[英]How do I change the placeholder color of <input> that it is inside <mat-form-field> from angular material?

我正在嘗試使用 .CSS 將輸入元素上的占位符顏色更改為白色。 它在里面的元素

  <mat-form-field class="text-center">
    <input class="daniel" matInput (keyup)="applyFilter($event.target.value)" placeholder="Search-bar">
  </mat-form-field>

Angular Material 組件顏色依賴於主題。 這意味着您可以創建自定義主題來完成這項工作。 如果有幫助,查看如何創建主題: https : //material.angular.io/guide/theming

另一個解決方案可能是覆蓋 css 樣式,但我目前確實掌握了輸入組件內占位符的知識

主題化是為材質組件着色的正確方法,但是,如果您想手動覆蓋材質輸入中的標簽,您可以這樣做:

::ng-deep .mat-form-field.mat-focused .mat-form-field-label {
    color:white;
}

https://stack59148369.stackblitz.io

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM