且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CSS 字体速记中的正斜杠是什么意思?

更新时间:2023-02-20 17:13:09

12px 是字体大小,18px 是行高.

12px is the font size, 18px is the line height.

语法基于用于指定相应大小的印刷符号,并且仅适用于 font 速记属性.换句话说,上面的声明简单地扩展为以下内容:

The syntax is based on typographical notation for specifying the respective sizes, and is only applicable to the font shorthand property. In other words, the above declaration simply expands to the following:

font-size: 12px;
line-height: 18px;

与往常一样,如果您将行高设置为相对值(例如百分比或 em),则它是相对于字体大小计算的.

As always, if you set the line height to a relative value (e.g. percentage or ems), it's calculated relative to the font size.

W3C CSS2.1 font 属性参考
W3C CSS3 字体模块font 属性参考(语法继承自 CSS2.1)

W3C CSS2.1 font property reference
W3C CSS3 Fonts Module font property reference (the syntax carries over from CSS2.1)