发现这段代码在样式表:字体百分比
.dropcap
{
float:left;
font:normal 290%/85%;
line-height:90%;
padding-right:0.02em;
margin-bottom:-0.1em;
}
有人能告诉我百分比(290%和85%)代表着什么?我认为85%是线路高度,但我显然是错的。
发现这段代码在样式表:字体百分比
.dropcap
{
float:left;
font:normal 290%/85%;
line-height:90%;
padding-right:0.02em;
margin-bottom:-0.1em;
}
有人能告诉我百分比(290%和85%)代表着什么?我认为85%是线路高度,但我显然是错的。
的290%应该是font-size
,你说得对,85%应该是不过line-height
的是,font
速记声明是不完整的:它应该做什么。您需要在font
中简写为font-family
,因为它是有效的属性值。
font:normal 290%/85% 'Times New Roman', Times, serif;
编辑:没有,哪怕是预处理代码,它仍然是一个无效的属性值。
这不是纯粹的CSS。你可能使用LESS或类似的,它可以做数学。
你没看错,但声明是不完整的,你必须得指定FONT-FAMILY。
虽然,该行之后的行将行高设置为90%。
https://developer.mozilla.org/en-US/docs/Web/CSS/font#Syntax
/* Set the font size to 12px and the line height to 14px. Set the font family to sans-serif */
p { font: 12px/14px sans-serif }
谢谢大家的回答,帮助我理解了这个概念。 – kenhelm