css - 在预先构建的角度材料主题上更改字体
问题描述
是否可以更改预建的角材料主题的字体,例如 deeppurple-amber.css?
我只找到创建自定义主题的示例,您必须自己定义几乎所有内容。我真的只对设置自己的字体感兴趣。
解决方案
请找到以下代码以更改默认字体
@import "~@ng-select/ng-select/themes/material.theme.css";
@import '~@angular/material/theming';
// Define a custom typography config that overrides the font-family as well as the
// `headlines` and `body-1` levels.
$custom-typography: mat-typography-config(
$font-family: 'Roboto',
$display-4: mat-typography-level(112px, 112px, 300),
$display-3: mat-typography-level(56px, 56px, 400),
$display-2: mat-typography-level(45px, 48px, 400),
$display-1: mat-typography-level(34px, 40px, 400),
$headline: mat-typography-level(24px, 32px, 400),
$title: mat-typography-level(20px, 32px, 500),
$subheading-2: mat-typography-level(16px, 28px, 400),
$subheading-1: mat-typography-level(15px, 24px, 400),
$body-2: mat-typography-level(14px, 24px, 500),
$body-1: mat-typography-level(14px, 20px, 400),
$caption: mat-typography-level(12px, 20px, 400),
$button: mat-typography-level(14px, 14px, 500),
$input: mat-typography-level(inherit, 1.125, 400)
);
@include mat-base-typography($custom-typography);
// Override typography for a specific Angular Material components.
@include mat-checkbox-typography($custom-typography);
// Override typography for all Angular Material, including mat-base-typography and all components.
@include angular-material-typography($custom-typography);
@include mat-core($custom-typography);
将此代码添加到您的主 css 文件或基本 css 文件中,并根据需要更改字体名称。
推荐阅读
- javascript - 在 JS 中基于鼠标位置 3D 效果创建透视框时出现错误
- android - 为什么我的应用程序在互联网关闭时仍然崩溃
- c# - 如何在 ASP.NET Core 5 运行时动态重新配置服务?
- python - Python如何在编写和重命名文件后为谷歌云存储文件生成签名的url?
- visual-studio - 是否可以在不按暂停和继续的情况下“热重载”ASP.NET Core 应用程序?
- css - 使用 CSS 网格,是否可以在间隙中添加边框线?
- javascript - 如何在javascript中迭代数组(不是元素)的属性?
- reactjs - 试图从表reactjs中的firebase获取数据
- javascript - HTML 表上的“querySelectorAll”未按预期工作
- file - 通过 lambda 下载大文件 - 受配额限制