HTML-DOM Stil Eigenschaft fontweight
Definition und Verwendung
Fontweight-Eigenschaft legt oder gibt den Gewichts Schriftart.
Grammatik
Einstellen Eigenschaften fontweight:
Object.style.fontWeight="value"
Zurück Eigenschaften fontweight:
Object.style.fontWeight
值 | 描述 |
---|---|
normal | 默认。字体是 normal(正常的)。 |
lighter | 定义更细的字体。 |
bold | 定义粗体。 |
bolder | 定义更粗的字体。 |
100 200 300 400 500 600 700 800 900 |
定义由细到粗的字符。400 等同于 normal,700 等同于 bold。 |
inherit | fontWeight 属性的值从父元素继承。 |
Browser-Unterstützung
Alle gängigen Browser unterstützen fontweight Eigenschaft.
Hinweis: IE7 und früheren Versionen nicht unterstützen , die "erben" Wert.IE8 bietet nur! DOCTYPE unterstützt "erben". IE9 Unterstützung "erben".
Beispiele
Beispiele
Ändern Sie font-weight:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Titel> Dieses Tutorial (w3big.com) </ title>
<Script>
Funktion displayResult () {
document.getElementById ( "P1") style.fontWeight = "900" .;
}
</ Script>
</ Head>
<Body>
<P id = "p1"> Dies ist ein Text. </ P>
<br>
<Taste type = "button" Onclick = "displayResult ()"> ändern Schriftstärke </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Titel> Dieses Tutorial (w3big.com) </ title>
<Script>
Funktion displayResult () {
document.getElementById ( "P1") style.fontWeight = "900" .;
}
</ Script>
</ Head>
<Body>
<P id = "p1"> Dies ist ein Text. </ P>
<br>
<Taste type = "button" Onclick = "displayResult ()"> ändern Schriftstärke </ button>
</ Body>
</ Html>
Versuchen »
Style - Objekte