font
font 简写属性在一个声明中设置所有字体属性。
可设置的属性是(按顺序): “font-style font-variant font-weight font-size/line-height font-family”
font-size和font-family的值是必需的。
语法
值
值 | 描述 |
---|---|
font-style | 规定字体样式。 |
font-variant | 规定字体异体。 |
font-weight | 规定字体粗细 |
font-size/line-height | 规定字体尺寸和行高。 |
caption | 定义被标题控件(比如按钮、下拉列表等)使用的字体。 |
icon | 定义被图标标记使用的字体。 |
menu | 定义被下拉列表使用的字体。 |
message-box | 定义被对话框使用的字体。 |
small-caption | caption 字体的小型版本。 |
status-bar | 定义被窗口状态栏使用的字体。 |
例子
HTML
<p class="ex1">This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</p> <p class="ex2">This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.</p>
CSS
p.ex1 { font:15px arial,sans-serif; } p.ex2 { font:italic bold 12px/30px Georgia,serif; }
执行结果
This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.
This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.