使用简写声明设置一些字体属性:
p.a {
font: 15px Arial, sans-serif;
}
p.b {
font: italic small-caps bold 12px/30px Georgia, serif;
}
亲自试一试 »
下面有更多 "亲自试一试" 示例。
这个font
property 是以下属性的简写:
font-size 和 font-family 值是必需的。如果缺少其他值之一,则使用它们的默认值。
笔记:line-height 属性设置行之间的间距。
默认值: | 字体属性的默认值 |
---|---|
遗传: | 是的 |
可动画: | 是的,查看各个属性。阅读可动画的尝试一下 |
版本: | CSS1 |
JavaScript 语法: | 对象.style.font="italic small-caps bold 12px arial,sans-serif"尝试一下 |
表中的数字指定完全支持该属性的第一个浏览器版本。
Property | |||||
---|---|---|---|---|---|
font | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
笔记:请参阅下面每个值的各个浏览器支持。
font:
font-style
font-variant
font-weight
font-size/line-height font-family|caption|icon|menu|message-box|small-caption|status-bar|initial|inherit;
Property/Value | Description | Demo |
---|---|---|
font-style | Specifies the font style. Default value is "normal" | Demo ❯ |
font-variant | Specifies the font variant. Default value is "normal" | Demo ❯ |
font-weight | Specifies the font weight. Default value is "normal" | Demo ❯ |
font-size/line-height | Specifies the font size and the line-height. Default value is "normal" | Demo ❯ |
font-family | Specifies the font family. Default value depends on the browser | Demo ❯ |
caption | Uses the font that are used by captioned controls (like buttons, drop-downs, etc.) | |
icon | Uses the font that are used by icon labels | |
menu | Uses the fonts that are used by dropdown menus | |
message-box | Uses the fonts that are used by dialog boxes | |
small-caption | A smaller version of the caption font | |
status-bar | Uses the fonts that are used by the status bar | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
一些其他字体属性值的演示。
<p style="font:caption">The browser font used in captioned controls.</p>
<p style="font:icon">The browser font used in icon labels.</p>
<p style="font:menu">The browser font used in dropdown menus.</p>
<p style="font:message-box">The browser font used in dialog boxes.</p>
<p style="font:small-caption">A smaller version of the caption font.</p>
<p style="font:status-bar">The browser font used in the status bar.</p>
亲自试一试 »
CSS教程:CSS 字体
HTML DOM 参考:字体属性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!