CSS字体的简写? [英] CSS Font shorthand?
问题描述
我基本上是通过使用简写属性来将font-style缩写为font。但是,如果我在同一选择器上指定了其他属性(大小/行高/字体系列),它似乎只能工作。
如果我注释掉任何额外的规范,那么斜体将被忽略!我在这里丢失了一些东西,或者我不应该使用
$ $ p $ $ $ $ c $ .main $ font size = / code>
而不是(例如)
.main {font-style:italic;}
或
$ b $
.main {
font:italic 1em / 1.2em georgia,times new roman,serif;}
$那么,使用字体缩写的最低要求是什么?解决方案 font-family 和 font-size 是此样式属性所需的最小样式。
完整速记的例子如下:
font:bold italic small-caps 1em / 1.5em verdana,sans-serif
这将取代下面的原始代码:
font-weight:bold;
font-style:italic;
font-variant:small-caps;
font-size:1em;
line-height:1.5em;
font-family:verdana,sans-serif
I was basically trying to abbreviate "font-style" to just "font" by using the shorthand property. However, it only seems to work if I specify other properties (size/line height/font-family) too on the same selector.
If I comment out any additional specification, the "italic" is ignored! Am I missing something here or am I just not supposed to use
.main{font:italic;}
instead of (for instance)
.main{font-style:italic;}
or
.main{
font:italic 1em/1.2em georgia,"times new roman",serif;}
So, what's the minimum requirements for using the font shorthand?
The font-family and font-size are the minimum styles required for this style property.
Example:
font: 1em "Times New Roman", Times, serif;
An example of a full shorthand would be the following:
font: bold italic small-caps 1em/1.5em verdana,sans-serif
This would replace the original code below:
font-weight: bold;
font-style: italic;
font-variant: small-caps;
font-size: 1em;
line-height: 1.5em;
font-family: verdana,sans-serif
这篇关于CSS字体的简写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!