角度材质排版设置

问题描述 投票:0回答:1

我无法在我的网络应用程序上使用此功能,因此我从 cli 创建了一个新项目(Angular 15),并使用“ng add @angular/material”添加了材料。

我将 app.component.html 编辑为简单的

<div>
  <h1>This is an h1.</h1>
  <h2>This is an h2.</h2>
</div>

现在是好东西。我的 styles.scss 是

@use '@angular/material' as mat;

@include mat.core();

$my-typography: mat.define-typography-config();
@include mat.typography-hierarchy($my-typography);

$my-custom-typography-config: mat.define-typography-config(
  $headline-1: mat.define-typography-level(112px, 112px, 300, $letter-spacing: -0.05em),
);

@include mat.typography-hierarchy($my-custom-typography-config);

当我检查 h1 时,Chrome DevTools 显示

为了让这个应用程序读取我尝试设置的值,我缺少什么? 我尝试将其设置为我的真实应用程序中主题的一部分,但我也无法让这些排版设置在那里工作。

angular angular-material typography
1个回答
0
投票

确保您已将课程添加到您的

index.html
。验证
<body>
标签是否包含
class="mat-typography"
。如果缺少,请像这样添加:

<body class="mat-typography">
© www.soinside.com 2019 - 2024. All rights reserved.