如何使用自定义字体的HTML?

问题描述 投票:-2回答:1

我从dafonts.com本地下载一个.TTF文件,我想知道如何轻松地在我的网站上使用它。它被称为永远的蝙蝠侠(链接:https://www.dafont.com/batman-forever.font)。任何帮助的新手?

<html>
  <head>
    <style>
    body {
    height: 3000px;
    background: linear-gradient(180deg, #0fb8ad 0%, #7c0fb8 85%);
    }
    </style>
  </head>
<body>
  <center>
  <h1>Hello</h1>
  </center>
</body>
</html>

我想看到的字体工作的只是我的标题(“你好”)。电流输出是在默认字体。

html
1个回答
0
投票

你需要将其添加在样式(为例):

@font-face {
    font-family: myFirstFont;(choose the name for your font here)
    src:local("C:\Users\Website\fonts\Harlow_Solid_Italic.ttf");(put the link of font in your local computer)
}

body{
    font-family: myFirstFont; (write your font name here)
}
© www.soinside.com 2019 - 2024. All rights reserved.