CSS Font Face“?#iefix” [英] CSS Font Face "?#iefix"
问题描述
我有一个关于css @ font-face的问题。我使用以下代码从此网站(http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax)。
I have a question about css @font-face. I'm using the following code from this website (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).
@font-face {
font-family: 'MyFontFamily';
src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'),
url('myfont-webfont.woff') format('woff'),
url('myfont-webfont.ttf') format('truetype'),
url('myfont-webfont.svg#svgFontName') format('svg');
}
<最后是否有 #iefix
?
推荐答案
这是因为IE8和以下解释字体声明的方式。正常的 url('myfont-webfont.eot')
将导致这些版本的IE中的404服务器错误;添加?#iefix
可修复服务器问题。 (这是因为同样的原因有IE的条件样式表。)
It's because of the way IE8 and below interpret font declarations. The normal url('myfont-webfont.eot')
would lead to 404 Server errors in these versions of IE; adding the ?#iefix
fixes the server issues. (It's for the same reason there's conditional stylesheets for IE.)
根据Fontspring(直接从源):
According to Fontspring (straight from the source):
Internet Explorer< 9在src属性的解析器中有一个错误。如果在src中包含多个字体格式,IE将无法加载它并报告404错误。原因是IE尝试加载作为文件的一切之间的开始括号一直到最后一个闭括号。要处理这种错误的行为,您只需首先声明EOT并附加一个问号。问号愚者IE认为其余的字符串是一个查询字符串,只加载EOT文件。其他浏览器遵循规范,并根据src级联和格式提示选择所需的格式。
Internet Explorer <9 has a bug in the parser for the src attribute. If you include more than one font format in the src, IE fails to load it and reports a 404 error. The reason is that IE attempts to load as a file everything between the opening parenthesis all the way to the very last closing parenthesis. To deal with that wrong behavior, you merely declare the EOT first and append a single question mark. The question mark fools IE into thinking the rest of the string is a query string and loads just the EOT file. The other browsers follow the spec and select the format they need based on the src cascade and the format hint.
所需的部分是?
;我想象 #iefix
只是程序员的一个语义行,不是由浏览器以任何特定的方式解释。
So the part that's necessary is the ?
; I imagine the #iefix
is just a semantic line for programmers that isn't interpreted by the browser in any particular way.
如果您愿意,还可以提供一些其他信息: https://github.com/stubbornella/csslint/ wiki / Bulletproof-font-face 。
Here's some more information if you would like: https://github.com/stubbornella/csslint/wiki/Bulletproof-font-face.
这篇关于CSS Font Face“?#iefix”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!