CSS3 @font-face 规则
在 CSS3 之前,web 设计师必须使用已在用户计算机上安装好的字体。
通过 CSS3,web 设计师可以使用他们喜欢的任意字体。
当您您找到或购买到希望使用的字体时,可将该字体文件存放到 web 服务器上,它会在需要时被自动下载到用户的计算机上。
您“自己的”的字体是在 CSS3 @font-face 规则中定义的。
Firefox、Chrome、Safari 以及 Opera 支持 .ttf (True Type Fonts) 和 .otf (OpenType Fonts) 类型的字体。
Internet Explorer 9+ 支持新的 @font-face 规则,但是仅支持 .eot 类型的字体 (Embedded OpenType)。
注释:Internet Explorer 8 以及更早的版本不支持新的 @font-face 规则。
使用您需要的字体
在新的 @font-face 规则中,您必须首先定义字体的名称(比如 myFirstFont),然后指向该字体文件。
如需为 HTML 元素使用字体,请通过 font-family 属性来引用字体的名称 (hoverTreeFont).
先查看效果:
完整HTML代码:
CSS3自定义字体 - 何问起 @font-face { font-family src @font-face { font-family src font-weight .hvtbold { font-family .hvtbold a div 加了自定义字体的效果: With CSS3, websites can finally use fonts other than the pre-selected "web-safe" fonts. 何问起 hovertree.com 柯乐义 CMS源代码下载原文首页更多特效没加自定义字体的效果: With CSS3, websites can finally use fonts other than the pre-selected "web-safe" fonts. 何问起 hovertree.com 柯乐义 CMS源代码下载原文首页更多特效
web前端: