【问题标题】:@font-face not working in Chrome and Firefox@font-face 在 Chrome 和 Firefox 中不起作用
【发布时间】:2013-10-16 01:55:00
【问题描述】:

我在使用两种浏览器的网站中遇到了@font-face 问题:Firefox 和 Chrome。

在 Firefox 中,@font-face 规则不起作用,它使用备用字体 —Helvetica —

我已经在样式表的顶部声明了这样的字体:

@font-face {
font-family: 'pf_centro_sans_proregular';
src: url('http://static.algarabia.com/CDN/fonts/pfcentrosanspro-reg-webfont.eot');
src: url('http://static.algarabia.com/CDN/fonts/pfcentrosanspro-reg-webfont.eot?#iefix') format('embedded-opentype'),
     url('http://static.algarabia.com/CDN/fonts/pfcentrosanspro-reg-webfont.woff') format('woff'),
     url('http://static.algarabia.com/CDN/fonts/pfcentrosanspro-reg-webfont.ttf') format('truetype'),
     url('http://static.algarabia.com/CDN/fonts/pfcentrosanspro-reg-webfont.svg#pf_centro_sans_proregular') format('svg');
font-weight: normal;
font-style: normal;

}

如果我在浏览器中输入 URI,它会毫无问题地下载字体,因此,字体就在那里(Opera 和 Safari 以正确的字体显示网站)

在 Chrome 中突然(我猜有一些更新)菜单更改为备用字体,是的,只是菜单,网站的其余部分按预期运行。

我知道字体在那里,我的 CSS 不应该那么糟糕,因为它可以在 Safari(桌面和移动)和 Opera 中使用。

有什么提示吗?

感谢您的时间和帮助。

【问题讨论】:

  • 你真的在任何地方使用过这个字体吗?这样做似乎对我有用(Chrome/OSX)jsfiddle.net/UhuVB
  • 您的 static.algarabia.com 服务器是否发送了正确的标头以允许跨站点访问字体?
  • @brbcoding 是的,我在菜单和所有段落中都使用它。
  • @BorisZbarsky 我已将字体移至主服务器,但问题仍然存在
  • 我设法让它在 Firefox 中工作,遵循这个答案:stackoverflow.com/questions/2856502/… 我已将一个 .htaccess 文件添加到字体所在的文件夹中,Firefox 现在按应有的方式显示该站点。跨度>

标签: css google-chrome firefox font-face


【解决方案1】:

只需将字体 url 从 http://fonts.googleapis.com/css 更改为 https://fonts.googleapis.com/css 即可保护此链接。

【讨论】:

    猜你喜欢
    • 2013-01-04
    • 2012-08-19
    • 2014-05-19
    • 2012-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-18
    • 2011-10-20
    相关资源
    最近更新 更多