CSS中的字体大小与斜杠 [英] Size of font in CSS with slash
问题描述
这里的斜线是什么意思:
What does the slash mean here:
font: 100%/120%;
推荐答案
这实际上设置了两个属性, / p>
This actually sets two properties and is equivalent to:
font-size: 100%;
line-height: 120%;
引用官方文档:
此属性的语法基于传统的排版速记符号设置与字体相关的多个属性。
The syntax of this property is based on a traditional typographical shorthand notation to set multiple properties related to fonts.
正如David M在评论中所说,指定字体大小为 x pt在 y pt上的传统,表示行高上的字形大小。
As David M said in the comments, it mirrors the typesetting tradition of specifying typeface sizes as "x pt on y pt" to denote the glyph size on line height.
但是你的问题中的例子实际上是错误的,并且会被浏览器忽略:你只能在 font
简写符号中组合这两个属性,并且你必须至少指定字体大小和家庭。因此,简单地写 font:100%/ 120%;
是不够的;您可以添加一个通用家族名称,使其有效,例如:
But the example in your question is actually wrong and would be ignored by the browser: you can only combine these two properties in the font
shorthand notation, and you must specify at least both the font size and family. Simply writing font: 100%/120%;
is therefore not enough; you could add a generic family name to make it valid though, e.g.:
font: 100%/120% serif;
这篇关于CSS中的字体大小与斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!