CSS @font-face 在 IE8 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7582401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:45:09  来源:igfitidea点击:

CSS @font-face not working in IE8

cssfont-face

提问by hackshockr

I have tried reading multiple articles on how to deal with custom fonts in IE, but they never seemed to work for me. I tried converting the fonts to EOT, but that didn't seem to work either. I am not sure what I am doing wrong, so I will post my code

我曾尝试阅读多篇关于如何在 IE 中处理自定义字体的文章,但它们似乎从来都不适合我。我尝试将字体转换为EOT,但这似乎也不起作用。我不确定我做错了什么,所以我会发布我的代码

@font-face {
  font-family: "Klavika Regular";
    src: url('../fonts/klavika.eot');
    src: local('a?o'), url('../fonts/klavika.woff') format('woff'), url('../fonts/klavika.ttf') format('truetype'), url('../fonts/klavika.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

回答by albert

this works in ie8/9

这适用于 ie8/9

http://dev.bowdenweb.com/a/fonts/serif/alegreya/demo.html

http://dev.bowdenweb.com/a/fonts/serif/alegreya/demo.html

@font-face {
    font-family: 'AftaserifRegular';
    src: url('AftaSerifThin-Regular-webfont.eot');
    src: url('AftaSerifThin-Regular-webfont.eot?#iefix') format('embedded-opentype'),
         url('AftaSerifThin-Regular-webfont.woff') format('woff'),
         url('AftaSerifThin-Regular-webfont.ttf') format('truetype'),
         url('AftaSerifThin-Regular-webfont.svg#AftaserifRegular') format('svg');
    font-weight: normal;
    font-style: normal;

}

回答by Naoise Golden

if IE8 thinksit supports any other format other than eotof the ones listed below, then it will probably try to use that one. Maybe you could use a IE8 hack, like

如果 IE8认为它支持eot下面列出的格式以外的任何其他格式,那么它可能会尝试使用该格式。也许你可以使用 IE8 hack,比如

src: local('a?o'), url('../fonts/klavika.woff') format('woff'), url('../fonts/klavika.ttf') format('truetype'), url('../fonts/klavika.svg') format('svg');
src /*\**/: url('../fonts/klavika.eot')

so only IE8 will read the last srcline and thus load the .eot.

所以只有 IE8 会读取最后src一行,从而加载 .eot。

回答by fine

Try three kinds of CSS Formats for @font-face on FontSquirrel Generator(in "EXPERT..." mode > in section "CSS Formats:" > "more information")

FontSquirrel Generator上为 @font-face 尝试三种 CSS 格式(在“专家...”模式下>在“CSS格式:”>“更多信息”部分)

回答by magicspon

It's worth checking to see if your .htaccess file allows the file type.

值得检查您的 .htaccess 文件是否允许该文件类型。