css3学习总结6--CSS3字体

使用自己需要的字体

在新的 @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-family name 必需。规定字体的名称。
src URL 必需。定义字体文件的 URL。
font-stretch
  • normal
  • condensed
  • ultra-condensed
  • extra-condensed
  • semi-condensed
  • expanded
  • semi-expanded
  • extra-expanded
  • ultra-expanded
可选。定义如何拉伸字体。默认是 "normal"。
font-style
  • ormal
  • italic
  • oblique
可选。定义字体的样式。默认是 "normal"。
font-weight
  • normal
  • bold
  • 100
  • 200
  • 300
  • 400
  • 500
  • 600
  • 700
  • 800
  • 900
可选。定义字体的粗细。默认是 "normal"。
unicode-range unicode-range 可选。定义字体支持的 UNICODE 字符范围。默认是 "U+0-10FFFF"。
 
原文地址:https://www.cnblogs.com/shuiche/p/4624474.html