สไตล์ตัวอักษรน้ำหนักทรัพย์สิน
ตัวอย่าง
ตั้งค่าน้ำหนักแบบอักษรสำหรับองค์ประกอบเป็น "900":
document.getElementById("demo").style.fontWeight = "900";
ความหมายและการใช้งาน
คุณสมบัติ fontWeight ตั้งค่าหรือส่งคืนว่าอักขระหนาหรือบางในข้อความควรแสดงอย่างไร
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
fontWeight | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติ fontWeight:
object.style.fontWeight
ตั้งค่าคุณสมบัติ fontWeight:
object.style.fontWeight = "normal|lighter|bold|bolder|value|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
normal | Font is normal. This is default |
lighter | Font is lighter |
bold | Font is bold |
bolder | Font is bolder |
100 200 300 400 500 600 700 800 900 |
Defines from light to bold characters. 400 is the same as normal, and 700 is the same as bold |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
รายละเอียดทางเทคนิค
ค่าเริ่มต้น: | ปกติ |
---|---|
คืนมูลค่า: | สตริงที่แสดงถึงความกล้าหาญของฟอนต์ |
เวอร์ชัน CSS | CSS1 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
การสาธิตค่าที่เป็นไปได้:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontWeight = listValue;
ตัวอย่าง
ส่งคืนน้ำหนักแบบอักษรขององค์ประกอบ:
alert(document.getElementById("demo").style.fontWeight);
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: แบบอักษร CSS
การอ้างอิง CSS: คุณสมบัติน้ำหนักแบบอักษร
การอ้างอิง HTML DOM: คุณสมบัติแบบอักษร
❮ สไตล์วัตถุ