propriedade HTML DOM Estilo fontSize
estilo Objects
Definição e Uso
TamanhoDoTipoDeLetra conjuntos de propriedades ou devolve o tamanho da fonte do texto.
gramática
Definindo as propriedades TamanhoDoTipoDeLetra:
Object.style.fontSize="value|inherit"
Propriedades volta TamanhoDoTipoDeLetra:
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 属性的值从父元素继承。 |
Suporte a navegadores
Todos os principais navegadores suportam fontSize propriedade.
Nota: IE7 e versões anteriores não suportam o valor "herdar".IE8 só fornece! DOCTYPE suportado "herdar". suporte IE9 "herdar".
Exemplos
Exemplos
Alterar o tamanho da fonte do texto:
<! DOCTYPE html>
<Html>
<Head>
<Charset Meta = "utf-8">
<Title> Este tutorial (w3big.com) </ title>
<Script>
displayResult function () {
document.getElementById ( "P1") style.fontSize = "xx-large" .;
}
</ Script>
</ Head>
<Body>
<P id = "p1"> Este é um texto. </ P>
<br>
<Button type = "button" onclick = "displayResult ()"> Alterar o tamanho da fonte </ button>
</ Body>
</ Html>
<Html>
<Head>
<Charset Meta = "utf-8">
<Title> Este tutorial (w3big.com) </ title>
<Script>
displayResult function () {
document.getElementById ( "P1") style.fontSize = "xx-large" .;
}
</ Script>
</ Head>
<Body>
<P id = "p1"> Este é um texto. </ P>
<br>
<Button type = "button" onclick = "displayResult ()"> Alterar o tamanho da fonte </ button>
</ Body>
</ Html>
tente »
estilo Objects