【发布时间】:2014-04-23 23:12:04
【问题描述】:
CSS 中的 line-height 是从文本底部到下一行文本的底部吗?还是文本在行内垂直居中?
请看示例图片:
【问题讨论】:
-
来自 W3 文档:
On a block container element whose content is composed of inline-level elements, 'line-height' specifies the minimal height of line boxes within the element. The minimum height consists of a minimum height above the baseline and a minimum depth below it, exactly as if each line box starts with a zero-width inline box with the element's font and line height properties. We call that imaginary box a "strut." (The name is inspired by TeX.). -
第一个例子是
line-height的行为 -
左图是正确的 ;)
-
您经常会看到人们使用 Line-Height 来垂直对齐 div 内的单行文本,方法是将 line-height 设置为与 div 相同的高度。
-
今后,请不要交叉发布问题。找到最合适的网站并坚持使用该网站。我将在此处合并您的两个问题以合并答案。
标签: css