您的位置:首页 > Web前端 > CSS

css3学习总结6--CSS3字体

2015-07-06 15:23 645 查看

使用自己需要的字体

在新的 @font-face 规则中,您必须首先定义字体的名称(比如 myFirstFont),然后指向该字体文件。

如需为 HTML 元素使用字体,请通过 font-family 属性来引用字体的名称 (myFirstFont):

实例

<style>
@font-face
{
  font-family: myFirstFont;
  src:   url('singlemalta-webfont.ttf'),
      url('singlemalta-webfont.eot'); /* IE9+ */
}

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


 

使用粗体字体

您必须为粗体文本添加另一个包含描述符的 @font-face:

示例:

@font-face
{
  font-family: myFirstFont;
  src: url('singlemalta-webfont.ttf'),
      url('singlemalta-webfont.eot'); /* IE9+ */
  font-weight:bold;
}


  

 

字体描述符

下面的表格列出了能够在 @font-face 规则中定义的所有字体描述符:

描述符描述
font-familyname必需。规定字体的名称。
srcURL必需。定义字体文件的 URL。
font-stretchnormal

condensed

ultra-condensed

extra-condensed

semi-condensed

expanded

semi-expanded

extra-expanded

ultra-expanded

可选。定义如何拉伸字体。默认是 "normal"。
font-styleormal

italic

oblique

可选。定义字体的样式。默认是 "normal"。
font-weightnormal

bold

100

200

300

400

500

600

700

800

900

可选。定义字体的粗细。默认是 "normal"。
unicode-rangeunicode-range可选。定义字体支持的 UNICODE 字符范围。默认是 "U+0-10FFFF"。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: