侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

CSS Font Face“?#iefix”[复制]

2022-10-08 星期六 / 0 评论 / 0 点赞 / 93 阅读 / 1861 字

参见英文答案 > How does ?#iefix solve web fonts loading in IE6-IE8?4个答案我有一个关于css @ font-face的问题。我正在使用本网站的

...参见英文答案 > How does ?#iefix solve web fonts loading in IE6-IE8?4个答案我有一个关于css @ font-face的问题。我正在使用本网站的以下代码(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');}

为什么“url(‘myfont-webfont.eot?#iefix’)”行末尾有“#iefix”?

.

解决方法

. 这是因为IE8及以下解释字体声明的方式。普通网址(‘myfont-webfont.eot’)会导致这些IE版本出现404服务器错误;添加?#iefix修复了服务器问题。 (这与IE的条件样式表的原因相同。)

根据Fontspring(直接来源):

.

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只是程序员的语义行,不会被浏览器以任何特定的方式解释。

如果您愿意,可以在此处获取更多信息:https://github.com/stubbornella/csslint/wiki/Bulletproof-font-face。

. ..

广告 广告

评论区