HTML DOM propiedad Estilo fontSize
Definición y Uso
fontSize conjuntos de propiedades o devuelve el tamaño de fuente de texto.
gramática
Configuración de las propiedades Tamaño de fuente:
Object.style.fontSize="value|inherit"
Volver propiedades Tamaño de fuente:
Object.style.fontSize
值 | 描述 |
---|---|
xx-small x-small small medium large x-large xx-large |
把字体的尺寸设置为不同的固定尺寸,从 xx-small 到 xx-large。 |
smaller | 把字体尺寸减小一个相对单位。 |
larger | 把字体尺寸增大一个相对单位。 |
length | 使用 px、cm 等单位定义字体尺寸。 |
% | 定义字体尺寸为父元素字体尺寸的某个百分比。 |
inherit | fontSize 属性的值从父元素继承。 |
Soporte para el navegador
Todos los principales navegadores soportan la propiedad fontSize.
Nota: Internet Explorer 7 y versiones anteriores no son compatibles con el valor "heredar".IE8 sólo proporciona! DOCTYPE apoyado "hereda". apoyo IE9 "hereda".
Ejemplos
Ejemplos
Cambiar el tamaño de fuente del texto:
<! DOCTYPE html>
<Html>
<Head>
<Charset Meta = "UTF-8">
<Title> Este tutorial (w3big.com) </ title>
<Script>
displayResult función () {
document.getElementById ( "P1") style.fontSize = "xx-large" .;
}
</ Script>
</ Head>
<Cuerpo>
<P id = "p1"> Esto es un texto. </ P>
<br>
<Botón type = "button" onclick = "displayResult ()"> Tamaño de la fuente botón </>
</ Body>
</ Html>
<Html>
<Head>
<Charset Meta = "UTF-8">
<Title> Este tutorial (w3big.com) </ title>
<Script>
displayResult función () {
document.getElementById ( "P1") style.fontSize = "xx-large" .;
}
</ Script>
</ Head>
<Cuerpo>
<P id = "p1"> Esto es un texto. </ P>
<br>
<Botón type = "button" onclick = "displayResult ()"> Tamaño de la fuente botón </>
</ Body>
</ Html>
Trate »
Objetos de estilo