为了账号安全,请及时绑定邮箱和手机立即绑定

选择选项后,如何将 Angular Material mat-autocomplete 文本颜色更

选择选项后,如何将 Angular Material mat-autocomplete 文本颜色更

largeQ 2023-12-25 16:13:01
我不想更改占位符颜色,因为我已经完成了,但选择一个选项后,文本颜色仍然是黑色。这是我的 HTML<form *ngIf="videos">    <mat-form-field class="search-form">      <input type="text" placeholder="Search Gamer-Tags" aria-label="Number" matInput [formControl]="myControl"        [matAutocomplete]="auto">      <mat-autocomplete #auto="matAutocomplete" autoActiveFirstOption (optionSelected)='searchChange($event.option.value)'>        <mat-option class="auto-option" *ngFor="let option of filteredOptions | async" [value]="option">          {{option}}        </mat-option>      </mat-autocomplete>    </mat-form-field>  </form>这是我的 SCSS::ng-deep .mat-focused .mat-form-field-label {color: white !important;}::ng-deep .mat-form-field-underline, ::ng-deep .mat-form-field-ripple {background-color: white !important; color: white !important }::ng-deep .mat-form-field-empty.mat-form-field-label { color: white !important;}::ng-deep .mat-form-field-ripple { background-color: white;}
查看完整描述

3 回答

?
人到中年有点甜

TA贡献1895条经验 获得超7个赞

要删除垫输入自动填充,background color您可以简单地使用 在您的主要 style.scss/css您可以使用


.mat-form-field-autofill-control{

  background-color: wheat; // your prefered color 

}


查看完整回答
反对 回复 2023-12-25
?
婷婷同学_

TA贡献1844条经验 获得超8个赞

对于角度 10


组件.sccs


.buscador {

    color: white !important;

}


:host ::ng-deep .mat-form-field-underline {

    background-color: white !important; 

 }

 :host ::ng-deep .mat-focused .mat-form-field-underline .mat-form-field-ripple {

 background-color: white !important;

}


组件.html


  <form>

    <mat-form-field>

        <mat-label id="placeholder" class="buscador">Buscar...</mat-label>

        <input type="text" aria-label="Number" matInput [formControl]="myControl" [matAutocomplete]="auto" type="text" name="option" required minlength="3">

        <mat-autocomplete #auto="matAutocomplete" name="option">

            <mat-option *ngFor="let option of options | async" [value]="option">

                {{option}}

            </mat-option>

        </mat-autocomplete>

    </mat-form-field>

</form>


查看完整回答
反对 回复 2023-12-25
?
摇曳的蔷薇

TA贡献1793条经验 获得超6个赞

我确实找到了如何更改它,需要添加此代码来更改输入的类颜色。

::ng-deep input.mat-input-element { color: white; }


查看完整回答
反对 回复 2023-12-25
  • 3 回答
  • 0 关注
  • 77 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信