css - 如何在 ffonts.net 上使用@font-face 更改字体

标签 css fonts webfonts

我正在制作一个专用于 Playstation 的致敬页面,并且想使用我找到的一种网络字体。我一直在尝试使用 @font-face 属性来实现它,但我似乎做错了什么

https://css-tricks.com/snippets/css/using-font-face/ 这是我一直试图遵循的指南。 https://webfonts.ffonts.net/Slim-Play.font 这是我假设的 webfont 服务器链接,但此时我不确定。

@font-face {
  font-family: 'slimplay';
  src:  url('https://webfonts.ffonts.net/Slim-Play.woff2') format('woff2'),
        url('https://webfonts.ffonts.net/Slim-Play.woff') format('woff'),
        url('https://webfonts.ffonts.net/Slim-Play.tts') format('truetype');
}
h1 {
  color: blue;
  font-family: "slimplay";
}

我希望 font-family: "slimplay"使其成为指定的字体,但在使用通用 h1 标签进行测试后,唯一出现的是蓝色。

最佳答案

@font-face 的格式没问题;我查看了您的字体链接,它们似乎无效。我的建议是在本地下载它们,然后上传到文件托管站点(如 Dropbox)并用这些替换您当前的字体链接。 Here是一个教程。

如果您决定使用 Dropbox,这里有一个示例:

@font-face {
  font-family: 'slimplay';
  src:  url('https://dl.dropbox.com/s/asdfghjkl/Slim-Play.woff2') format('woff2'),
        url('https://dl.dropbox.com/s/asdfghjkl/Slim-Play.woff') format('woff'),
        url('https://dl.dropbox.com/s/asdfghjkl/Slim-Play.ttf') format('truetype');
}

(并且您的 CSS 样式可以保持不变)

希望对你有帮助

关于css - 如何在 ffonts.net 上使用@font-face 更改字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57174127/

相关文章:

php - 为什么我不能在 WordPress functions.php 中加入多个 Google 字体?

javascript - 改变背景图片,Jquery + CSS

java - 如何从 View 类访问我的 Assets ?

css - 字体在 Firefox 上不起作用。在别人身上效果很好

javascript - 加载网络字体后如何收到通知

javascript - 为什么会发生这种换行?

css - 如何使用 css 在顶部添加功能区?

css - 如何修复 font-stretch 属性以开始工作

c++ - 使用 CreateFont() 创建时,Tahoma(MS Shell Dlg 2)字体在 Win7 中看起来被压扁了

font-face - Webfont (@font-face) 行高问题