简体   繁体   English

更改垫子选项字体系列,用于垫子 Select - Angular 材料

[英]Change Mat Option Font Family for Mat Select - Angular Material

I am attempting to change the font of the options inside mat-select ("In what city were you born", etc).我正在尝试更改 mat-select 中选项的字体(“您出生在哪个城市”等)。

I noticed if I set ViewEncapsulation to none (eg let styles bleed in from other files), it does allow me to change the font family, but setting this to none causes other unwanted styles to bleed in even though I have these all set to ":host"我注意到如果我将 ViewEncapsulation 设置为无(例如让 styles 从其他文件中渗入),它确实允许我更改字体系列,但是将其设置为无会导致其他不需要的 styles 渗入,即使我将这些都设置为“ :主持人”

在此处输入图像描述

Note: I noticed when I change the font for this class in dev tools that it changes the font successfully:注意:当我在开发工具中更改此 class 的字体时,我注意到它成功更改了字体:

在此处输入图像描述

However when I add the style to my css file and try it even with ng-deep, it still doesn't change the font.但是,当我将样式添加到我的 css 文件并尝试使用 ng-deep 时,它仍然不会更改字体。

add this to your styles.css / styles.scss file in your Angular project:将此添加到 ZC31C335EF37283C451BDE18 项目中的 styles.css / styles.scss 文件中:

.mat-option-text {
  font-size: 16px !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !important;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM