CSS ?#iefix 如何解决 IE6-IE8 中网页字体加载的问题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8050640/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does ?#iefix solve web fonts loading in IE6-IE8?
提问by vine'th
Lots of articles in the web like this : http://www.fontspring.com/blog/fixing-ie9-font-face-problemssuggest to add a ?#iefix
to the eot url. I was curious to know howis this going to solve the problem. Thanks.
网络上有很多这样的文章:http: //www.fontspring.com/blog/fixing-ie9-font-face-problems建议?#iefix
在eot url 中添加a 。我很好奇,想知道怎么这是要解决的问题。谢谢。
回答by Rexy Hoang
IE8 and the older have a bug in their parsers for the src attribute. So if you include more than 1 font format in the SRC, IE fails to load it and reports a 404 error.
The question mark solves that problem as it fools IE into thinking the rest of the string (other src) is a query string, and therefore loading just the EOT file...
Other browsers will follow the specification and load just their required font type ...
You may wanna read Paul Irish's Bulletproof @font-face syntaxto know more about some other of the why's ...
IE8 和旧版本的 src 属性解析器中存在错误。所以如果你在 SRC 中包含了 1 种以上的字体格式,IE 将无法加载它并报告 404 错误。
问号解决了这个问题,因为它让 IE 认为字符串的其余部分(其他 src)是一个查询字符串,因此只加载 EOT 文件......
其他浏览器将遵循规范并仅加载他们所需的字体类型。 ..
您可能想阅读 Paul Irish 的Bulletproof @font-face 语法以了解更多关于其他一些原因的信息......
回答by basarat
You could do anything instead of ?#iefix
: The basic objective is to put a ?#something
after the first font file in the URL as @Rexyz has already answered.
您可以做任何事情而不是?#iefix
:基本目标是?#something
在 URL 中的第一个字体文件之后放置一个,因为@Rexyz 已经回答了。
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#FooAnything') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
回答by basarat
Fully realising this is an old question.
完全意识到这是一个老问题。
But for those who came here looking for what version of "that" browser needed this hack, it's safe now to remove if you don't support IE<10.
但是对于那些来到这里寻找“那个”浏览器的哪个版本需要这个 hack 的人来说,如果你不支持 IE<10,现在删除它是安全的。
So just get rid of it and have just one line enumerating all fonts in all formats you offer.
因此,只需摆脱它,只需一行列出您提供的所有格式的所有字体。
回答by atwright147
The ?#iefix
is there to stop the browser interpreting any characters after the ?
as a query string and therefore prevents another possible server error.
的?#iefix
是那里阻止浏览器后解释任何字符?
作为查询字符串,从而防止另一种可能的服务器错误。