基于创建反应的项目添加了字体,但不起作用

发布于 2025-01-29 15:46:43 字数 400 浏览 4 评论 0 原文

我正在使用Create-React-App,而不是不弹出。 我在index.html文件中导入。并给它默认字体。但是它不起作用。

<style>
        @font-face {
            font-family: Gumela;
            src: url("../src/fonts/*");
        }
        * {
            font-family: "Gumela";
            font-weight: normal;
            font-size: 20px;
        }
        body {
            margin: 0;
        }
    </style>

I'm using create-react-app and prefer not to eject.
i imported in index.html file . and give it default font. but its not working.

<style>
        @font-face {
            font-family: Gumela;
            src: url("../src/fonts/*");
        }
        * {
            font-family: "Gumela";
            font-weight: normal;
            font-size: 20px;
        }
        body {
            margin: 0;
        }
    </style>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

月亮坠入山谷 2025-02-05 15:46:43

您可以在app.css文件上插入字体脸

@font-face {
  font-family: Gumela;
  src: url('./fonts/Gumela\ Regular.otf');
}

You can insert font-face on your App.css file

@font-face {
  font-family: Gumela;
  src: url('./fonts/Gumela\ Regular.otf');
}
情绪操控生活 2025-02-05 15:46:43

尝试在app.css或index.css文件中导入字体。

然后尝试:

 @font-face {
            font-family: Gumela;
            src: url("../src/fonts/*");
            font-display: swap; // This will swap font once its loaded, for SEO purpose.
        }


* {
    font-family: Gumela;
    font-weight: normal;
    font-size: 20px;

    OR

    font: Gumela normal 20px;
  }

Try importing the fonts in your app.css or index.css file.

And try:

 @font-face {
            font-family: Gumela;
            src: url("../src/fonts/*");
            font-display: swap; // This will swap font once its loaded, for SEO purpose.
        }


* {
    font-family: Gumela;
    font-weight: normal;
    font-size: 20px;

    OR

    font: Gumela normal 20px;
  }
无人问我粥可暖 2025-02-05 15:46:43

我在这里导入字体:和它对我有用。

I imported the font here: https://www.onlinewebfonts.com/download/00561b492d88a5287a5def1e83a34882 and it worked for me.

绮筵 2025-02-05 15:46:43

只需在您的样式标签之前将其添加到头。

&lt; link href =“ // db.onlinewebfonts.com/c/c/00561b492d88a5287a5287a5287a5def1e83a34882?family = gumela“

just add this in head before your style tag.

<link href="//db.onlinewebfonts.com/c/00561b492d88a5287a5def1e83a34882?family=Gumela" rel="stylesheet" type="text/css"/>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文