【问题标题】:Font Not applying in React Application字体不适用于 React 应用程序
【发布时间】:2020-06-23 11:05:57
【问题描述】:

我正在从 google 字体导入字体并将该字体应用于索引页面的所有元素。

但不应用这些字体

在 index.html 中

<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">

index.css

 .body {
  margin: 0;
  padding: 0;
  font-family: 'Press Start 2P'; }

【问题讨论】:

  • 你真的有一个元素有class="body"吗?
  • @GuyIncognito 可能他在 body 类上应用这个 font 而不是在 <body> 标签上

标签: html css reactjs


【解决方案1】:

看到这个作品,也许你正在尝试改变body标签,将.body替换为body

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
body {
  margin: 0;
  padding: 0;
  font-family: 'Press Start 2P', cursive;
}
Hello World!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-13
    • 2023-03-10
    • 2021-09-19
    • 2021-11-19
    • 2021-05-29
    • 2020-04-24
    • 2019-07-03
    • 1970-01-01
    相关资源
    最近更新 更多