【问题标题】:IE9 @font-face bluesIE9 @font-face 蓝调
【发布时间】:2012-08-09 17:24:01
【问题描述】:

所以 IE9 在使用 google 字体时会报错,如下所示:

<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,900" rel="stylesheet" type="text/css" />

IE9 吐出一个错误,即使字体仍然可以正常加载:

CSS3111: @font-face encountered unknown error. 

如果我不是在其他人的网页上编写 iframe 的内容,我很乐意忽略此错误。 :(

在本地托管 EOT 文件可以解决 IE 的问题:

< !--[if IE 9]>
< link rel="stylesheet" href="/survey/css/lato-ie.css" type="text/css" />
< ![endif]-->

在那个文件里..

@font-face {
    font-family: "Lato";
    font-style: normal;
    font-weight: 400;
    src: url("/Lato-Reg-webfont.eot") format("embedded-opentype");
}
@font-face {
    font-family: "Lato";
    font-style: normal;
    font-weight: 900;
    src: url("/Lato-Bla-webfont.eot") format("embedded-opentype");
}

将它包含在 IE9 中,错误消失了,效果很好。

现在我的问题是,我需要为除 IE9 之外的所有人添加 google 字体样式表。例如,我不能这样做:

< !--[if !IE 9]>
< link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,900" rel="stylesheet" type="text/css" />
< ![endif]-->

否则 Firefox 甚至不会看到该死的包含。

IE 的开发者是否在密谋浪费我们所有的时间?

【问题讨论】:

  • 托管所有浏览器的字体是否有很大的劣势?
  • 除了努力和可扩展性之外别无其他(我将需要为我无法保证获得 .woff、.ttf 和 .svg 的字体执行此操作,让单独.eot)..

标签: css internet-explorer-9 font-face


【解决方案1】:

你在正确的轨道上,你只需要使用downlevel-revealed conditional comment:它会在 IE 中隐藏它,但会被其他浏览器拾取。

【讨论】:

  • 想解释一下否决票?也许你不明白他的问题,但我的解决方案解决了它。
  • 我为你投票将它归零,这是问题的 100% 答案,也很紧凑和简单。非常好!
【解决方案2】:

一个问题,您是否尝试在本地查看文件?

即使您链接到绝对外部链接,谷歌字体也不会在本地呈现。 (如果是 IE)

localhost/project/index.html = good
C:\Project\index.html = bad

【讨论】:

  • 好问题,我正在通过本地服务器查看它们(不是 C: 路径)。
猜你喜欢
  • 1970-01-01
  • 2012-06-10
  • 2013-04-05
  • 2013-05-18
  • 2012-09-21
  • 1970-01-01
  • 1970-01-01
  • 2012-06-22
  • 1970-01-01
相关资源
最近更新 更多