基线与基线之间的距离
西安软件研发中心x西安软件研发中心x

决定普通行内盒子的高度


纯内联元素的可视高度完全由 line-height 决定

非替换元素的纯内联元素

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste officiis illum veritatis? Adipisci aspernatur repudiandae a omnis sit, excepturi, eius odit veritatis non quisquam aut aliquam architecto iusto aliquid placeat! Demo Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae, molestias suscipit! A odit sunt aperiam iure officia quae possimus placeat! Hic cumque, libero voluptatum exercitationem officiis eligendi laboriosam esse laborum.


line-height 取值

下面三者有什么区别?


line-height 的数字值

大多数情况下,推荐使用数字设置line-height,这不会在继承时产生不确定的结果。

Avoid unexpected results by using unitless line-height.

父级 line-height: 1.5em

子元素直接继承 1.5em * 15px = 22.5px

Avoid unexpected results by using unitless line-height.

父级 line-height: 150%

子元素直接继承 150% * 15px = 22.5px

Avoid unexpected results by using unitless line-height.

父级 line-height: 1.5

计算得到 1.5 * 30px = 45px