html - 如何使用我从 css 文件导入的字体

标签 html css fonts

这是我在我的 css 样式表中添加的代码:

        @font-face 
{
        font-family: 'space_rangerregular';
        src: url('spaceranger-webfont.woff2') format('woff2'),
             url('spaceranger-webfont.woff') format('woff');
        font-weight: normal;
        font-style: normal;
    }

我将其与 h6 相关联:

h6{
  font-size: 12px;
  font-family:"Space Ranger Regular", serif;
}

然后在我的 HTML 文件中(我链接了 css 表)我做了:

<h6>Test</h6>

但是我的代码不显示字体。有什么问题吗?

最佳答案

使用您在 @font-face 部分为 font-family 分配给 font-family 的相同值用它。所以,对于你的 h6:

h6{
  font-size: 12px;
  font-family: space_rangerregular, serif;
}

关于html - 如何使用我从 css 文件导入的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54431448/

相关文章:

javascript - 多选复选框值显示在按钮 Vanilla js 上

html - 如何使用 CSS 将自定义字体插入到文本中?

javascript - 如何在 Textarea 元素中显示数组

python - Django,ModelMultipleChoiceField 中的初始值仅设置为禁用

javascript - HTML 无法识别我要求它运行的 javascript 文件,SyntaxError : Unexpected token '<' (anonymous function)script. js:1

HTML5 PostMessage 跨域问题

html - 如何让元素掉落而不是在导航栏中并排放置 - bootstrap 4

javascript - Webpack-开发工具 : source-map for CSS and eval-source-map for JS?

css - 字体粗细 :900 only working in Firefox

css - NextJs 中未加载本地字体