我为 IE 8 创建了一个测试页面,看看我是否可以使用 Google 字体。您可以在问题末尾找到代码。
我通过使用带有列表的元素来包含我需要的所有 Google 字体。
现在,根据元素中 HREF 属性的长度,Google 字体可能无法在 IE 8 中使用。
案例如下:
如果我有:
<link rel=stylesheet type="text/css"
href="//fonts.googleapis.com/css?family=Tangerine|Open+Sans|Droid+Sans|PT+Sans|Josefin+Slab|Arvo|Lato" />
Google 字体不能在 IE 8 中使用。
现在,如果我删除“Lato”,最后指定的字体:
<link rel=stylesheet type="text/css"
href="//fonts.googleapis.com/css?family=Tangerine|Open+Sans|Droid+Sans|PT+Sans|Josefin+Slab|Arvo" />
Google 字体在 IE 8 中正常工作。
在这两种情况下,它们在 Chrome 中都运行良好,这仅与 IE 8 相关。
测试页面的HTML代码:
<html>
<head>
<link rel=stylesheet type="text/css"
href="//fonts.googleapis.com/css?family=Tangerine|Open+Sans|Droid+Sans|PT+Sans|Josefin+Slab|Arvo|Lato" />
<style>
div {
font-size: 36px;
font-family: 'Tangerine'; /* here is the google font */
}
</style>
</head>
<body>
<div>This div will get the google font family</div>
</body>
</html>
最佳答案
是的,这是 IE 的问题 - 对于 IE8 及以下版本 - 一种解决方案是在条件语句中分离出每种字体的链接 - 它不喜欢链接属性中的长字体堆栈跟踪。
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Tangerine" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Droid+Sans" />
<![endif]-->
关于css - Internet Explorer 8 中的字体问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30650026/