且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

FontAwesome不会在Firefox中显示

更新时间:2022-10-20 23:31:05

你有没有尝试引导CDN ?



只需包括&LT;链接HREF =// netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-在你的< head> 部分中设置awesome.css =stylesheet> 字体文件也将从CDN自动加载。



在Firefox上检查了这一点,它完美的工作。



@Boris说:


如果字体所在的服务器发送,Firefox只允许跨域连接字体正确的CORS头。

所以很明显,它是 CDN责任来设置正确的标题,不是你的。他们似乎这样做是正确的,因为Firefox不会抱怨。



如果您在自己的服务器上托管字体,请记住,跨域规则可能仍然适用,例如 domain.com 中的字体文件可能无法从 www.domain.com 访问,如果 www.domain.com 不会发送正确的标题。



阅读此答案,以获得有关绕过跨子域限制的提示 - 这可能有助于您的情况。


Related question here.

Boris' answer to the above question seems to make sense, but I installed the Font Awesome files on my server and the problem remains:

I looked into the library and found that the font files are included in the install, so the argument about cross-server access to fonts doesn't seem valid. I don't mind using the BootstrapCDN, but then Boris' suggestion seems to apply, and I don't know how to send the right CORS headers. (I tried it, but it doesn't work either.) Any idea how I can fix this, either using the "Bootstrap CDN" or the "default CSS"? (see also these instructions.)


PS: IE10 shows the glyph correctly.

Did you try Bootstrap CDN?

Just include <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> in your <head> section. Font files will be loaded automatically from CDN, too.

Checked this on Firefox and it works perfectly.

@Boris says:

Firefox only allows cross-domain linking of fonts if the server the font is on sends the right CORS headers.

So it's clear that it's CDNs duty to set the right headers, not yours. And them seem to do that correctly, because Firefox doesn't complain.

If you host fonts on your own server, keep in mind that cross-domain rule may still apply, e.g. font files places under domain.com may be unaccessible from www.domain.com, if www.domain.com doesn't send the right headers.

Read this answer for tips about bypassing cross-sub-domain restrictions - this might help in your case.