CSS引入特殊字体的属性font-face

font-face是CSS3 的新属性,目前Firefox、Chrome、Safari 以及 Opera 支持 .ttf (True Type Fonts) 和 .otf (OpenType Fonts) 类型的字体;Internet Explorer 9+ 支持新的 @font-face 规则,但是仅支持 .eot 类型的字体 (Embedded OpenType)。

在新的 @font-face 规则中,必须首先定义字体的名称(比如 myFirstFont),然后指向该字体文件路径,当需要时通过font-family调用该字体。

<style> 
@font-face
{
    font-family: myFont;
    src: url('Sansation_Light.ttf'),
}

div
{
font-family:myFont;
}
</style>

当网页商用时不建议使用未购买版权的字体,避免知识产权纠纷。

原文地址:https://www.cnblogs.com/tortoises/p/7515859.html