Style lineHeightPropiedad

Style 对象参考手册Objeto Style

Definición y uso

La propiedad lineHeight establece o devuelve la distancia entre líneas de texto.

Sintaxis

Establecer la propiedad lineHeight:

Object.style.lineHeight="normal|number|length|%|inherit"

Devolver la propiedad lineHeight:

Object.style.lineHeight

Valor Descripción
normal Predeterminado. Establece un espaciado de línea razonable.
number Establece un número; este número se multiplica por el tamaño de fuente actual para establecer el espaciado de línea.
length Define el espaciado de línea usando unidades como px, cm, etc.
% Define el espaciado de línea como un porcentaje del tamaño de fuente actual.
inherit El valor de la propiedad lineHeight se hereda del elemento padre.


Soporte del navegador

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Todos los navegadores principales admiten la propiedad lineHeight.

Nota:IE7 y versiones anteriores no admiten el valor "inherit". IE8 solo admite "inherit" si se especifica !DOCTYPE. IE9 admite "inherit".


Ejemplo

Ejemplo

Cambiar la altura de la línea:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<script>
function displayResult(){
    document.getElementById("div1").style.lineHeight="2";
}
</script>
</head>
<body>

<div id="div1">
Esto es un texto, esto es un texto. Esto es un texto, esto es un texto.
Esto es un texto, esto es un texto. Esto es un texto, esto es un texto.
Esto es un texto, esto es un texto. Esto es un texto, esto es un texto.
Esto es un texto, esto es un texto. Esto es un texto, esto es un texto.
</div>
<br>
<button type="button" onclick="displayResult()">Modificar altura de línea</button>

</body>
</html>

Pruébalo »


Style 对象参考手册Objeto Style Otras extensiones