我在一个网站上使用@font-face。代码运行良好,在Firefox、Chrome和Opera中,@ font -face字体加载完美。使用的代码与Font Squirrel生成的代码相同。这是@font-face代码:
@font-face {
font-family: 'OpenSansRegular';
src: url('fonts/OpenSans-Regular-webfont.eot');
src: url('fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/OpenSans-Regular-webfont.woff') format('woff'),
url('fonts/OpenSans-Regular-webfont.ttf') format('truetype'),
url('fonts/OpenSans-Regular-webfont.svg#OpenSansRegular') format('svg');
font-weight: normal;
font-style: normal;
}然后使用以下代码调用该字体:
font-family: "OpenSansRegular",Arial,sans-serif;然而,在IE9中,它仍然可以工作,但非常笨拙。最初加载页面时,首先加载Arial字体,大约1到2秒后加载OpenSansRegular字体。这显然会破坏网站的体验,因为页面加载了一种字体,然后在一段时间后将另一种字体引导到页面上。
有没有办法在仍然使用@font-face的情况下防止这种情况发生?
发布于 2012-06-06 17:00:13
在IE9中,完全支持data: attribute的使用。在这种情况下,您可以这样修改CSS:
@font-face {
font-family: 'OpenSansRegular';
src: url('data:font/eot;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAggg=='); /* IE 9 */
font-weight: normal;
font-style: normal;
}这将确保只有当CSS完全加载时,它才会加载字体。希望能有所帮助。
https://stackoverflow.com/questions/10911064
复制相似问题