目录

style lineHeight 属性

示例

设置 <div> 元素的行高:

document.getElementById("myDiv").style.lineHeight = "3";
亲自试一试 »

描述

lineHeight 属性设置或返回文本中行之间的距离。


浏览器支持

Property
lineHeight Yes Yes Yes Yes Yes

语法

返回 lineHeight 属性:

object.style.lineHeight

设置 lineHeight 属性:

object.style.lineHeight = "normal| number| length| %|initial|inherit"

属性值

Value Description
normal Normal line height is used. This is default
number A number that will be multiplied with the current font size to set the line height
length Defines the line height in length units
% Defines the line height in % of the current font size
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

技术细节

默认值: 普通的
返回值: 一个字符串,表示文本中行之间的距离
CSS版本 CSS1

更多示例

示例

返回 <div> 元素的行高:

alert(document.getElementById("myDiv").style.lineHeight);
亲自试一试 »

相关页面

CSS教程:CSS 文本

CSS 参考:行高属性