CSS3 @font-face的url要添加?#iefix的原因

转至:https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face

When using @font-face to 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.

转载于:https://www.cnblogs.com/jecyhw/p/3891537.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值