css @font-face属性怎么用

2020-07-22 22:35:48

css @font-face属性

指定名为"myFirstFont"的字体,并指定在哪里可以找到它的URL

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

css @font-face属性属性定义及使用说明

@font-face规则,网页设计师再也不必使用的"web-safe"的字体之一。

字体的名称,font - face规则

font-family: myFirstFont

字体文件包含在您的服务器上的某个地方,参考CSS

src: url('Sansation_Light.ttf')

如果字体文件是在不同的位置,请使用完整的URL

src: url('http://www.w3cschool.css/css3/Sansation_Light.ttf')

现在准备使用该字体,下面是如何使用它所有的div元素的一个例子

div{font-family: myFirstFont;}

语法

@font-face{font-properties}

以下实例为在div中使用的字体:

div{font-family: myFirstFont;}

语法

@font-face{font-properties}