澄清 CSS 字体大小到底测量什么
我正在阅读 Eric Meyer 的 CSS 权威指南第三版。
他关于字体大小的部分(第 107 页)指出字体大小决定了 em 框。如果我这样做:
span { font-size: 10px; }
它是否将 em 框的水平和垂直方向精确设置为 10px?他将测量值称为基线之间的距离。
我想我有点困惑为什么它被称为“盒子”而不只是高度,如果它所做的只是测量垂直距离。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
“em”可用作垂直或水平测量中的相对测量单位。
因此,如果当前的 font-size 设置为 12px,那么在子元素上设置 margin:1em 将在其周围创建 12px 的边距。如果您随后将父元素的字体大小更改为 16 像素,则边距也会增加到 16 像素。
"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.
阅读字体大小:'font-size' W3C 规范的属性..
Have a read of the Font size: the 'font-size' property of the W3C specification ..