您的位置:首页 > 其它

Shorthand Method for Text Formatting

2011-12-27 13:05 281 查看
CSS offers a shorthand property called font, which lets you combine the following properties into a single line: font-style ,font-variant ,font-weight , font-size , line-height , and font-family .

You don’t have to include every one of these properties, but you must include the font size and font family: font: 1.5em Georgia, Times, serif.

Use a single space between each property value.You use a comma only to separate fonts in a list like this: Arial, Helvetica, sans-serif.

When specifying the line height, add a slash after the font size followed by the line-height value, like this: 1.5em/150% or 24px/37px.

The last two properties must be font-size (or fontsize/line-height) followed by font-family, in that order. All the other properties may be written in any order. For example both font: italic bold small-caps
1.5em Arial; and font: bold small-caps italic 1.5em Arial; are the same.

Finally, omitting a value from the list is the same as setting that value to normal. Say you created a <p> tag style that formatted all paragraphs in bold, italics, and small caps with a line height of 2000 percent (not that you’d actually do that). If you then created a class style named, say, .special-Paragraph with the following font declaration font: 1.5em Arial; and applied it to one paragraph on the page, then that paragraph would not inherit the italics, bold, small caps, or line height. Omitting those four values in the .specialParagraph style is the same as writing this: font: normal normal normal 1.5em/normal Arial/;.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: