CSS3 @font-face的url要添加?#iefix的原因
2014-08-05 09:39
393 查看
转至:https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face
When using
Will cause a 404 in IE 6, 7, and 8. The fix is to add a question mark after the first font URL, so IE sees the rest of the property value as a query string. This is a correct example:
This rule is aimed at preventing 404 errors in Internet Explorer 8 and earlier due to a bug in how web font URLs are parsed.
The following patterns are considered warnings:
The following patterns are considered okay and do not cause warnings:
This rule requires that the first font declared is a .eot file with a query string, but doesn't check the order of the remaining fonts (which is irrelevant, assuming you have the .eot file first).
This rule was added in v0.9.10.
When using
@font-faceto declare multiple font types for cross browser compatibility, you can see 404's in old versions of IE due to a bug in the way that IE parses the font declarations. For example, this syntax:
@font-face { font-family: 'MyFontFamily'; src: url('myfont-webfont.eot') format('embedded-opentype'), url('myfont-webfont.woff') format('woff'), url('myfont-webfont.ttf') format('truetype'), url('myfont-webfont.svg#svgFontName') format('svg'); }
Will cause a 404 in IE 6, 7, and 8. The fix is to add a question mark after the first font URL, so IE sees the rest of the property value as a query string. This is a correct example:
@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'); }
Rule Details
Rule ID:bulletproof-font-face
This rule is aimed at preventing 404 errors in Internet Explorer 8 and earlier due to a bug in how web font URLs are parsed.
The following patterns are considered warnings:
@font-face { font-family: 'MyFontFamily'; /* First web font is missing query string */ src: url('myfont-webfont.eot') format('embedded-opentype'), url('myfont-webfont.woff') format('woff'), url('myfont-webfont.ttf') format('truetype'), url('myfont-webfont.svg#svgFontName') format('svg'); }
The following patterns are considered okay and do not cause warnings:
@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'); }
This rule requires that the first font declared is a .eot file with a query string, but doesn't check the order of the remaining fonts (which is irrelevant, assuming you have the .eot file first).
This rule was added in v0.9.10.
相关文章推荐
- CSS3 @font-face【转】
- CSS3: @font-face
- css3 @font-face设置嵌入字体
- CSS3 @font-face详细用法(转)
- 【css3】@font-face
- CSS3 @font-face 太神奇了!
- CSS3 @font-face
- CSS3 @font-face
- CSS3文字与字体:text-overflow 与 word-wrap、@font-face、文本阴影text-shadow
- CSS3 @font-face
- css3中font-face属性的用法详解
- CSS3中字体@font-face的使用
- CSS3 @font-face
- (转)CSS3 @font-face
- css3 @font-face
- 使用CSS3 @font-face实现个性化字体
- CSS3 @font-face
- 如何使用CSS3 @font-face
- CSS3 @font-face
- CSS3@font-face 使用与特别注意事项 (字体格式需woff)