Properti HTML DOM Style fontWeight
Definisi dan Penggunaan
fontWeight set properti atau mengembalikan berat badan font.
tatabahasa
Pengaturan properti fontWeight:
Object.style.fontWeight="value"
Sifat Kembali fontWeight:
Object.style.fontWeight
值 | 描述 |
---|---|
normal | 默认。字体是 normal(正常的)。 |
lighter | 定义更细的字体。 |
bold | 定义粗体。 |
bolder | 定义更粗的字体。 |
100 200 300 400 500 600 700 800 900 |
定义由细到粗的字符。400 等同于 normal,700 等同于 bold。 |
inherit | fontWeight 属性的值从父元素继承。 |
Dukungan Browser
Semua browser utama mendukung properti fontWeight.
Catatan: IE7 dan versi sebelumnya tidak mendukung "mewarisi" nilai.IE8 hanya menyediakan! DOCTYPE didukung "mewarisi". dukungan IE9 "mewarisi".
contoh
contoh
Mengubah font-weight:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
document.getElementById ( "p1") style.fontWeight = "900" .;
}
</ Script>
</ Kepala>
<Body>
<P id = "p1"> Ini adalah beberapa teks. </ P>
Situs
<Tombol type = "button" onclick = "displayResult ()"> memodifikasi berat Font </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Script>
Fungsi displayResult () {
document.getElementById ( "p1") style.fontWeight = "900" .;
}
</ Script>
</ Kepala>
<Body>
<P id = "p1"> Ini adalah beberapa teks. </ P>
Situs
<Tombol type = "button" onclick = "displayResult ()"> memodifikasi berat Font </ button>
</ Body>
</ Html>
Coba »
gaya Objects