【问题标题】:Cannot set font-family to AvantGard in React.js无法在 React.js 中将 font-family 设置为 AvantGard
【发布时间】:2020-02-18 00:53:44
【问题描述】:

我想在我的 React 应用程序的一个段落中添加 AvantGard 字体,但字体似乎没有效果,我不知道为什么,这是我添加它的方法:

  1. 我将它作为 ttf 文件保存在我的资产文件夹中。
  2. 我有全局 scss 文件 index.css,我在其中声明它是这样的:
@font-face {
  font-family: 'AvantGard';
  font-style: normal;
  src: url('./assets/fonts/avant_gartt/AvantGard.ttf');
}
  1. 我还有一个 variables.scss,我将其保存在其中:
$avantGard: 'AvantGuard';
  1. 我将变量导入到组件的 css 中,如下所示:
@import './variables.scss';

然后我只设置段落的字体大小:

 font-family: $avantGard;

有人知道为什么我的字体不起作用吗?我的其他字体的工作方式相同,但不是这个。

【问题讨论】:

  • 从 index.css 文件的上下文中字体文件的路径是否正确?在您的问题中显示您的文件结构可能会有所帮助。

标签: css reactjs fonts


【解决方案1】:

检查数字 3 的拼写。 AvantGard 还是 AvantGuard?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-11
    • 2011-02-14
    • 2016-10-12
    • 1970-01-01
    • 1970-01-01
    • 2018-01-30
    • 1970-01-01
    相关资源
    最近更新 更多