propriété HTML DOM style fontSize
Définition et utilisation
fontSize ensembles de propriétés ou retourne la taille de la police du texte.
grammaire
Définition des propriétés fontSize:
Object.style.fontSize="value|inherit"
Retour propriétés fontSize:
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 属性的值从父元素继承。 |
support du navigateur
Tous les principaux navigateurs prennent en charge la propriété fontSize.
Note: IE7 et les versions antérieures ne supportent pas la valeur "inherit".IE8 ne fournit DOCTYPE! Supporté "inherit". soutien IE9 "inherit".
Exemples
Exemples
Modifier la taille de la police du texte:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Titre> Ce tutoriel (w3big.com) </ title>
<Script>
fonction displayResult () {
document.getElementById ( "p1") style.fontSize = "xx-large" .;
}
</ Script>
</ Head>
<Body>
<P id = "p1"> Ceci est un texte. </ P>
<br>
<Bouton type = "button" onclick = "displayResult ()"> Modifier la taille </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Titre> Ce tutoriel (w3big.com) </ title>
<Script>
fonction displayResult () {
document.getElementById ( "p1") style.fontSize = "xx-large" .;
}
</ Script>
</ Head>
<Body>
<P id = "p1"> Ceci est un texte. </ P>
<br>
<Bouton type = "button" onclick = "displayResult ()"> Modifier la taille </ button>
</ Body>
</ Html>
Essayez »
style Objets