微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – 将自定义字体添加到GitHub页面

我刚刚在 GitHub上托管了我的新网站.我在那里使用了一些自定义字体,我在index.html和style.css文件旁边上传了这些字体:

enter image description here

字体代码

@font-face {
  font-family: "gogoiadeco";
  src: url('gogoia-deco-webfont.eot');
  src: url('gogoia-deco-webfont.eot?#iefix') format('embedded-opentype'),url('gogoia-deco-webfont.woff') format('woff'),url('gogoia-deco-webfont.ttf') format('truetype'),url('gogoia-deco-webfont.svg#Gogoia') format('svg');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'icomoon';
  src:url('icomoon.eot');
  src:url('icomoon.eot?#iefix') format('embedded-opentype'),url('icomoon.woff') format('woff'),url('icomoon.ttf') format('truetype'),url('icomoon.svg#icomoon') format('svg');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'gogoiaregular';
  src: url('gogoia-regular.eot');
  src: url('gogoia-regular.eot?#iefix') format('embedded-opentype'),url('gogoia-regular.woff2') format('woff2'),url('gogoia-regular.woff') format('woff'),url('gogoia-regular.ttf') format('truetype'),url('gogoia-regular.svg#gogoiaregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

我是GitHub的新手,我不知道要改变什么来使这些字体工作.

解决方法

我也有这个问题.我让字体在本地正常工作,但似乎无法在GitHub上正确使用它.

我想出了如何执行此操作:gitHub.io页面的根目录似乎与本地根目录不同,这导致错误文件夹中的字体.

这是我的代码

@font-face {
    font-family: F16;
    src: url("../SubSkipper/F16_Panel Font.ttf") format('truetype');
    font-weight: bold;
    font-style: normal;
}

SubSkipper是我的项目的名称,.ttf字体在明显的根目录中,我的意思是:“SubSkipper /”.

路径../返回一级,然后在本地显示项目的根目录(SubSkipper).

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐