@ font-face - 如何使其适用于所有浏览器

Kar*_*ine 4 html css internet-explorer font-face

Internet Explorer 9,Firefox,Opera,Chrome和Safari支持@ font-face规则.

但是,Internet Explorer 9仅支持.eot类型字体,而Firefox,Chrome,Safari和Opera支持.ttf和.otf类型字体.

注意:Internet Explorer 8及更早版本不支持@ font-face规则.

本文来自这里.所以为了让IE9的@ font-face工作,我应该只指定EOT字体文件:

@font-face
{
font-family: myFirstFont;
src: url('Sansation_Light.ttf'),
     url('Sansation_Light.eot'); /* IE9 */
}
Run Code Online (Sandbox Code Playgroud)

特别是我使用Myriad Pro,我有OTF字体.我如何将它们转换为EOT类型?

关于IE7和IE8应该使用什么技巧/黑客来获得所需的结果?

jac*_*per 9

我认为这几乎是完全跨浏览器

@font-face {
    font-family: 'Name';
    src: url('location.eot');
    src: url('location.eot#iefix') format('embedded-opentype'),
         url('location.woff') format('woff'),
         url('location.ttf') format('truetype'),
         url('location.svg#Name') format('svg');
    font-weight: normal;
    font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)

位置是服务器上的路径,Name是字体的名称

  • 如果我们要"在所有浏览器上工作",那么请不要理会重量和样式属性.IE <9不支持它们,并采用仿粗等方式.更好地将所有权重等定义为不同命名的字体. (2认同)