# line-height

line-height CSS 属性用于设置多行元素的空间量,如多行文本的间距。对于块级元素,它指定元素行盒(line boxes)的最小高度。对于非替代的 inline 元素,它用于计算行盒(line box)的高度。

# uni-app x 兼容性

Android iOS web
3.9 4.11 4.0

# 语法

line-height: normal | <number> | <length> | <percentage>;

# line-height 的属性值

normal 取决于用户代理。桌面浏览器(包括 Firefox)使用默认值,约为 1.2,这取决于元素的 font-family。

# 默认值

平台 默认值
uvue 1.2

注意:W3C 默认值为:normal

# 适用组件

# 兼容性

# line-height 的属性值兼容性

Android iOS web
normal x x 4.0

# 浏览器兼容性

Chrome Edge Firefox Opera Safari IE
line-height √( 1 ) √( 12 ) √( 1 ) √( 7 ) √( 1 ) √( 4 )

# App平台

App平台仅支持以像素值(px)、相对像素值(rpx)和相对当前元素字体字体单位(em),em单位表示数字值乘以该元素的字体大小,无单位值时使用em,默认值为1.2em。 line-height 样式不支持继承,仅对 text 组件生效。 建议设置大于15%字号大小的值,以避免出现渲染异常。

不支持百分比的值 不支持设置关键字 normal 值 不支持ch、rem、ex等单位

# Web规范

line-height 样式支持继承,默认值为normal(大约为1.2em,取决于 font-family 样式)

# 参见