css - @font face 仅在演示 html 中显示

标签 css font-face

好的,所以我从 fontsquirell 下载了一个 @font-face 工具包,它在下载中包含的演示 html 文件中工作正常,但是当我将它放在任何其他文件或子文件夹中时无法呈现。

我已经检查了文件结构并进行了相应的链接,我仍然遇到这个问题。对我应该做什么有什么建议吗?

@font-face {
font-family: 'BreeSerifRegular';
src: url('..assets/fonts/BreeSerif-Regular-webfont.eot');
src: local("☺")
     url('..assets/fonts/BreeSerif-Regular-webfont.eot?#iefix') format('embedded-    opentype'),
     url('..assets/fonts/BreeSerif-Regular-webfont.woff') format('woff'),
     url('..assets/fonts/BreeSerif-Regular-webfont.ttf') format('truetype'),
     url('..assets/fonts/BreeSerif-Regular-webfont.svg#BreeSerifRegular') format('svg');
font-weight: normal;
font-style: normal;
}

相同的格式适用于其他字体,不知道为什么它不适用于此。

最佳答案

这是路径的基本问题

将您收到的字体复制到根目录下的一个文件夹中,比如一个font

然后将您的 css 指向以相对模式读取文件

@font-face {
font-family: 'BreeSerifRegular';
src: url('fonts/BreeSerif-Regular-webfont.eot');
src: local("☺")
     url('fonts/BreeSerif-Regular-webfont.eot?#iefix') format('embedded-    opentype'),
     url('fonts/BreeSerif-Regular-webfont.woff') format('woff'),
     url('fonts/BreeSerif-Regular-webfont.ttf') format('truetype'),
     url('fonts/BreeSerif-Regular-webfont.svg#BreeSerifRegular') format('svg');
font-weight: normal;
font-style: normal;
}

更新

你定义相对路径的方式是错误的

..assets 更改为 ../assets

关于css - @font face 仅在演示 html 中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9594817/

相关文章:

css - Chrome 和 Firefox 中不同的行高

css - 试图将 Logo 放在 CSS 图像 slider 的顶部

javascript - 更改全屏背景并在 DIV 悬停时添加文本

html - 包含 2 个或更多元素的内联 block

css - 在我的 CSS 中使用 Lato 字体 (@font-face)

html - github 页面字体和 index.html 不工作

c# - 在 asp.net C# 中动态创建/复制 Div

twitter-bootstrap - 为什么 CSS 在我使用 Bootstrap 的网站上的 Google Chrome 浏览器中不起作用? @font-face 可能是问题所在吗?

html - 垂直对齐按钮文本?

css - 使用 CSS 使用自定义字体?