css - 通过 CSS 嵌入字体;似乎没有任何效果

标签 css fonts embed

我在这里遇到了很多问题,但我不明白为什么我正在做的事情不起作用——但事实并非如此。我想在网站中使用一些非标准字体,通过 css 嵌入。

这是我从 FontSquirrel 获得的 CSS 的样子:

@font-face {
    font-family: 'CrimsonRoman';
    src: url('Crimson-Roman-webfont.eot');
    src: url('Crimson-Roman-webfont.eot?#iefix') format('embedded-opentype'),
         url('Crimson-Roman-webfont.woff') format('woff'),
         url('Crimson-Roman-webfont.ttf') format('truetype'),
         url('Crimson-Roman-webfont.svg#CrimsonRoman') format('svg');
    font-weight: normal;
    font-style: normal;

这是在我的主要 CSS 样式表中引用它的地方:

p {
  margin: 0 0 9px;
  font-family: 'CrimsonRoman', Garamond, Times, Times New Roman, serif;
  font-size: 13px;
  line-height: 18px;
}

现在一切都在同一个目录中,所以我什至还没有处理在目录中导航的问题。 “p”声明本身似乎有效,因为如果我将第一个术语更改为“Crimson”,即字体在我计算机上的名称,它会正常加载(或者如果我将其切换为我在本地安装的任何其他字体).不管是什么问题,我都没有看到。

在我的 html 文档中,两个工作表都已成功链接,并且字体链接在主工作表之前。

我正在使用 Firefox 进行测试。

最佳答案

确保您的目录路径正确并指向您的字体在服务器上所在的文件夹。

否定

@font-face {
    font-family: 'CrimsonRoman';
    src: url('/fonts/Crimson-Roman-webfont.eot');
    src: url('/fonts/Crimson-Roman-webfont.eot?#iefix') format('embedded-opentype'),
         url('/fonts/Crimson-Roman-webfont.woff') format('woff'),
         url('/fonts/Crimson-Roman-webfont.ttf') format('truetype'),
         url('/fonts/Crimson-Roman-webfont.svg#CrimsonRoman') format('svg');
    font-weight: normal;
    font-style: normal;
}

关于css - 通过 CSS 嵌入字体;似乎没有任何效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10422478/

相关文章:

css - OpenERP 6.0 中如何自定义元素的字体和颜色

html - 在 HTML 中嵌入 DWG 文件

php - 我如何制作一个表格来更新我的表格并在我的 TeamStats 页面上显示为一行?

html - <p> 标签的默认边距值是多少?

html - CSS 的@font-face local() 不会定位除 "regular"和 "bold"之外的其他字体样式

java - 在 GitHub 页面上嵌入 Java Applet

php - 如何跟踪嵌入式视频(youtube、vimeo 等)的点击事件? (跟踪播放次数)

css - line-height :1. 5 和 line-height :150% in css? 有什么区别

html - 可以使用 ionic2/3 更改 ionic 范围方向吗?

android - 为 Activity 中的所有 TextView 设置字体?