这个CSS字体的简写语法是什么意思? [英] What does this CSS font shorthand syntax mean?

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

问题描述

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

  font:12px / 18px ... 

12px / 18px c>

18px 是行高。



语法基于用于指定各自大小的印刷符号,适用于字体速记属性。换句话说,上面的声明简单地扩展为如下:

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

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



W3C CSS2.1 字体属性引用

W3C CSS3字体模块字体属性引用(从CSS2.1继承的语法)


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

font: 12px/18px ...

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

解决方案

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

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;

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 property reference
W3C CSS3 Fonts Module font property reference (the syntax carries over from CSS2.1)

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

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