Heim  >  Artikel  >  Web-Frontend  >  CSS font 复合属性的顺序_html/css_WEB-ITnose

CSS font 复合属性的顺序_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:44:192238Durchsuche

CSS 参考手册

实例

在一个声明中设置所有字体属性:

p.ex1  {  font:italic arial,sans-serif;  }p.ex2  {  font:italic bold 12px/20px arial,sans-serif;  }

亲自试一试

浏览器支持

IE Firefox Chrome Safari Opera
         

所有浏览器都支持 font 属性。

注释:任何的版本的 Internet Explorer (包括 IE8)都不支持属性值 "inherit"。

定义和用法

font 简写属性在一个声明中设置所有字体属性。

注释:此属性也有第六个值:"line-height",可设置行间距。

说明

这个简写属性用于一次设置元素字体的两个或更多方面。使用 icon 等关键字可以适当地设置元素的字体,使之与用户计算机环境中的某个方面一致。注意,如果没有使用这些关键词,至少要指定字体大小和字体系列。

可以按顺序设置如下属性:

  • font-style
  • font-variant
  • font-weight
  • font-size/line-height
  • font-family
  • 可以不设置其中的某个值,比如 font:100% verdana; 也是允许的。未设置的属性会使用其默认值。

    默认值: 继承性: 版本: JavaScript 语法:
    not specified
    yes
    CSS1
    object.style.font="italic small-caps bold 12px arial,sans-serif"

    可能的值

    值 描述
    font-style 规定字体样式。参阅:font-style 中可能的值。
    font-variant 规定字体异体。参阅:font-variant 中可能的值。
    font-weight 规定字体粗细。参阅:font-weight 中可能的值。
    font-size/line-height 规定字体尺寸和行高。参阅:font-size 和 line-height 中可能的值。
    font-family 规定字体系列。参阅:font-family 中可能的值。
    caption 定义被标题控件(比如按钮、下拉列表等)使用的字体。
    icon 定义被图标标记使用的字体。
    menu 定义被下拉列表使用的字体。
    message-box 定义被对话框使用的字体。
    small-caption caption 字体的小型版本。
    status-bar 定义被窗口状态栏使用的字体。

    TIY 实例

    所有字体属性在一个声明之内 本例演示如何使用简写属性将字体属性设置在一个声明之内。 设置使用 "caption" 值的段落字体 本例演示如何设置使用 "caption" 值的段落字体。

    相关页面

    CSS 教程:CSS 字体

    HTML DOM 参考手册:font 属性

    CSS 参考手册

    Stellungnahme:
    Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn