css font 属性的快捷写法


font:italic small-caps bold 12px/1.5em arial,verdana;

等效于

font-style:italic;

font-variant:small-caps;

font-weight:bold;

font-size:12px;

line-height:1.5em;

font-family:arial,verdana;

顺序:font-style | font-variant | font-weight | font-size | line-height | font-family

:简写时,font-size和line-height只能通过斜杠/组成一个值,不能分开写。)

不过使用这种简写需要注意几点:要使简写定义有效必须至少提供 font-size 和 font-family 这两个属性 ;同时font-weight, font-style 以及 font-varient 这几个属性如果不做设定的话将默认为normal。

font快捷写法的格式为

复制代码
代码如下:

  body {
    font: font-style font-variant font-weight font-size line-height font-family;
  }

所以,

复制代码
代码如下:

  body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    font-weight: normal;
    font-variant: small-caps;
    font-style: italic;
    line-height: 150%;
  }

可以被写成:

复制代码
代码如下:

  body {
    font: italic small-caps normal 13px/150% Arial, Helvetica, sans-serif;
  }

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3