CSS 字体速记中的正斜杠是什么意思? [英] What does the forward slash mean in the CSS font shorthand?

查看:21
本文介绍了CSS 字体速记中的正斜杠是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在样式表中看到以下 CSS 声明:

I'm seeing the following CSS declaration in a stylesheet:

font: 12px/18px ...

12px/18px 部分到底是什么意思?

What does the 12px/18px part mean exactly?

推荐答案

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)

这篇关于CSS 字体速记中的正斜杠是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆