樣式 fontWeight 屬性
描述
fontWeight 屬性用於設定或返回文字中字元的粗細。
瀏覽器支援
| 屬性 | |||||
|---|---|---|---|---|---|
| fontWeight | 是 | 是 | 是 | 是 | 是 |
語法
返回 fontWeight 屬性
object.style.fontWeight
設定 fontWeight 屬性
object.style.fontWeight = "normal|lighter|bold|bolder|value|initial|inherit"
屬性值
| 值 | 描述 |
|---|---|
| normal | 字型正常。這是預設值 |
| lighter | 字型更輕 |
| 粗體 | 字型粗體 |
| 更粗 | 字型更粗 |
| 100 200 300 400 500 600 700 800 900 |
定義從淺到粗的字元。400 與 normal 相同,700 與 bold 相同 |
| initial | 將此屬性設定為其預設值。閱讀關於 initial |
| inherit | 從其父元素繼承此屬性。閱讀關於 inherit |
技術詳情
| 預設值 | normal |
|---|---|
| 返回值 | 一個字串,表示字型的粗細 |
| CSS 版本 | CSS1 |
更多示例
示例
可能值的演示
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontWeight = listValue;
自己動手試一試 »
相關頁面
CSS 教程:CSS 字型
CSS 參考: font-weight 屬性
HTML DOM 參考:font 屬性