简体   繁体   English

@ font-face不会在Wordpress网站上的Firefox(5.01)中加载

[英]@font-face won't load in Firefox (5.01) on Wordpress-site

I have a problem with a Wordpress site. 我对Wordpress网站有疑问。 The @font-face is working in Safari and Chrome but not in Firefox 5.01. @ font-face在Safari和Chrome中有效,但在Firefox 5.01中无效。 I've used Fontsquirrel's font generator (http://www.fontsquirrel.com/fontface/generator) which generates ttf, woff, eot and svg fonts. 我使用了Fontsquirrel的字体生成器(http://www.fontsquirrel.com/fontface/generator),该生成器生成ttf,woff,eot和svg字体。

The problem seem to be related to the Wordpress site. 该问题似乎与Wordpress网站有关。 I've tested a plain html site with the same font and then Firefox is loading and displaying the font. 我已经测试了具有相同字体的纯HTML网站,然后Firefox 正在加载并显示该字体。

I've read that the problem can be related to CMD. 我读过,问题可能与CMD有关。 I've also heard that Firefox, for security reasons only load fonts if you hard code the exact URL (http://www.koodoz.com.au/klog/font-face-woe-with-wordpress-firefox/) and not the php link in Wordpress. 我还听说,出于安全原因,Firefox仅在您对确切的URL进行硬编码(http://www.koodoz.com.au/klog/font-face-woe-with-wordpress-firefox/)时才加载字体,并且不是Wordpress中的php链接。

The php wordpress site, notworking: link. php wordpress网站,不起作用:链接。 The html site, working: link html站点,工作:链接

The font won't load in Firefox. 字体不会在Firefox中加载。 Any idea? 任何想法?

From the Firefox error console: 从Firefox错误控制台:

Warning: @font-face rule not allowed within @media or @-moz-document rule.
Source File: http://ellenz.se/wp-content/themes/BLANK-Theme/style.css?1312303802
Line: 18

And indeed, the CSS grammar does not allow nesting @-rules, though there has been talk of possibly relaxing that restriction. 确实,CSS语法不允许嵌套@ -rules,尽管有传言称可能放宽该限制。 WebKit is just violating the spec here. WebKit只是违反了此处的规范。

FF's Firebug dom inspector shows that your "notworking" page's body style is being overridden by line 26 of your reset.css. FF的Firebug的 DOM查看器显示,你的“notworking”页面的body风格是由你的reset.css线26覆盖。 It would appear FF is treating the @import url as applying AFTER the rest of your style.css file. 看起来FF在将其余的style.css文件之后应用@import url作为处理。

Maybe you should have a look at the Google's font API . 也许您应该看看Google的font API It's pretty easy to use and even works with IE6. 它非常易于使用,甚至可以与IE6一起使用。

Just choose a font from the Google Font Directory , and then you only need to import it in your HTML-head-section (before the css): 只需从Google字体目录中选择一种字体,然后只需将其导入HTML头部(在CSS之前)即可:

<link rel="stylesheet" 
      type="text/css" 
      href="http://fonts.googleapis.com/css?family=Font+Name">

After that, you can use it in your css as a ragular font: 之后,您可以在CSS中使用它作为粗体字体:

body {
  font-family: 'Font Name', serif;
  font-size: 48px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM