css - CSS 行高是如何测量的?

标签 css

CSS 中的行高是从文本的底部到下一行文本的底部吗?还是文本在行内垂直居中?

请看示例图片:

enter image description here

最佳答案

Form MDN :

On block level elements, the line-height CSS property specifies the minimal height of line boxes within the element.

On non-replaced inline elements, line-height specifies the height that is used in the calculation of the line box height.


正如您在此 DEMO 中看到的那样 和下图。这意味着对于文本,line-height 定义框内垂直居中字母周围的框的高度,因此您的第一个示例是正确的

enter image description here

图片来自 www.w3.org

关于css - CSS 行高是如何测量的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23247800/

相关文章:

javascript - 未捕获类型错误鼠标滚轮不是函数

html - 修复有问题的过滤器 CSS 属性转换(Chrome)?

html - 在表格单元格中使用 CSS 居中表格

html - 如何绕三 Angular 形 block 流动?

css - LESS mixin 仅在同一样式表中声明时才起作用

html - 定位工具提示不相对于 "origin"[css]

jquery - 如何仅设置 html5 元素的样式?

html - 如何居中对齐图像链接并使其仅在图像而不是溢出区域上可点击?

javascript - 带有 getElementsByTagName 的嵌套标签名称不起作用

html - 如何在文本或文本字段的左侧显示工具提示