简体中文 
 line-height CSS 属性用于设置多行元素的空间量,如多行文本的间距。对于块级元素,它指定元素行盒(line boxes)的最小高度。对于非替代的 inline 元素,它用于计算行盒(line box)的高度。
| Web | Android | iOS | HarmonyOS | 
|---|---|---|---|
| 4.0 | 3.9 | 4.11 | 4.61 | 
line-height: normal | <number> | <length> | <percentage>;
| 名称 | 兼容性 | 描述 | 
|---|---|---|
| normal | 取决于用户代理。桌面浏览器(包括 Firefox)使用默认值,约为 1.2,这取决于元素的 font-family。 | 
| 平台 | 默认值 | 
|---|---|
| uvue | 1.2 | 
注意:W3C 默认值为:normal
示例为hello uni-app x alpha分支,与最新HBuilderX Alpha版同步。与最新正式版同步的master分支示例另见
示例
<template>
  <view style="flex-grow: 1;">
    <view style="height: 500px;background-color: gray;justify-content: center;align-items: center;">
      <text class="common" style="line-height: 75px;">line-height: 75px</text>
      <text class="line-height-3 common">line-height: 3</text>
      <text class="common" style="line-height: 3em;">line-height: 3em</text>
      <text class="common" style="line-height: 3;">line-height: 3\nline-height: 3\nline-height: 3</text>
    </view>
  </view>
</template>
<script>
</script>
<style>
  .common {
    font-size: 20px;
    border: 1px red solid;
    margin: 10px 0;
    padding: 0 10px;
  }
  .line-height-3 {
    line-height: 3;
  }
</style>
App平台仅支持以像素值(px)、相对像素值(rpx)和相对当前元素字体大小单位(em),em单位表示数字值乘以该元素的字体大小,无单位值时使用em,默认值为1.2em。 line-height 样式不支持继承,建议设置大于15%字号大小的值,以避免出现渲染异常。
不支持百分比的值 不支持设置关键字 normal 值 不支持ch、rem、ex等单位
line-height 样式支持继承,默认值为normal(大约为1.2em,取决于 font-family 样式)