且构网

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

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

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

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;

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

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)