澄清什么CSS字体大小措施 [英] Clarification what exactly CSS font-size measures

查看:164
本文介绍了澄清什么CSS字体大小措施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



字体大小部分(第107页)指出,字体大小决定了em箱子的大小。如果我这样做:

  span {font-size:10px; } 

是否将em框的水平和垂直设置为10px?他指的是作为基线之间的距离的测量。

我想我有点困惑,为什么它被称为一个盒子,而不是只是高度如果它只是测量垂直距离的话。

解决方案

测量。因此,如果当前字体大小设置为12px,那么在子元素上设置margin:1em会在其周围创建12px的边距。如果您随后将父元素的字体大小更改为16px,则边距也会增加到16px。


I'm reading CSS the definitive guide by Eric Meyer 3rd edition.

His section on font-sizes (page 107) states that font size determines the em box. If I do:

span { font-size: 10px; }

Does it set exactly the horizontal and the vertical of the em box to 10px? He refers to the measurement as being the distance between baselines.

I guess I'm a little confused on why it's referred to as a "box" instead of just em height if all it does is measure vertical distance.

解决方案

"em" is available as a relative unit of measure in both vertical or horizontal measurements.

So if the current font-size is set to 12px, then setting margin:1em on a child element would create a 12px margin around it. If you were then to change the font-size of the parent element to 16px, the margin would also increase to 16px.

这篇关于澄清什么CSS字体大小措施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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