角垫选择文本颜色不会改变

新手上路,请多包涵

我在我的 Angular 应用程序中使用 mat-select。我想更改文本颜色,但颜色没有改变。

 <mat-select style="color: red" [(ngModel)]="someValue">
  <mat-option>class="empty-select"</mat-option>
  <mat-option class="not-empty-select" *ngFor="let unit of units [value]="unit">{{unit}}</mat-option>
</mat-select>

我可以毫无问题地更改背景颜色,但文本颜色不会改变。

原文由 Nancy 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 571
1 个回答

这帮助我更改了所选文本的样式:

::ng-deep .mat-selected .mat-option-text { color: white!important; }

在此处输入图像描述

原文由 Artur Haiduk 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题