html - 浏览器呈现安全字体而不是本地

标签 html css fonts

当我在 chrome 或 firefox 中打开 devtools 时,找到我的 .page-header__hero-motivation 并看到渲染字体是 Comic Sans,而不是 Caveat。

@font-face {
  font-family: "Caveat";
  src: url("../fonts/Caveat-Regular.woff2") format(woff2),
    url("../fonts/Caveat-Regular.woff") format(woff);
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.page-header__hero-motivation {
  font-family: "Caveat", "Comic Sans MS", cursive;
  font-size: 18px;
  color: #8E80A9;
}

My website tree

index.html
css -> style.css
fonts -> Caveat-Regular.woff2 & Caveat-Regular.woff

从 googlefonts 获取此字体并在线转换为 woff&woff2。

chrome devtools

最佳答案

似乎 Comic Sans 是通用系列而不是字体系列。不要同时设置两者,只需设置字体或通用系列,另请参阅 https://developer.mozilla.org/en-US/docs/Web/CSS/font-family 告诉我它是否有效,否则请发布完整代码。

关于html - 浏览器呈现安全字体而不是本地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58201641/

相关文章:

css - Bootstrap 是否导入了两次?

javascript - 使用 javascript 立即获取输入[类型 ="file"] 值?

css - 半粗体重音字符错误

html - Highcharts 图例分页位置

javascript - html <输入需要包含特定文本

jquery - CSS 3 透视图和 z-index 不兼容

html - 在导航栏中创建事件状态箭头

jquery - 使用JQuery显示按钮的不同状态和显示/隐藏内容

javascript - 如何通过引用 .js 文件来呈现这些字体?

java - RHEL6 服务器 - 如果将字体添加到 java 字体目录,字体在 jsp 查看器上出现乱码但在导出时(来自同一查看器)完美,否则空指针异常