รูปแบบตัวอักษรขนาดคุณสมบัติ
ตัวอย่าง
กำหนดขนาดตัวอักษรขององค์ประกอบเป็น "x-large":
document.getElementById("demo").style.fontSize = "x-large";
ความหมายและการใช้งาน
ชุดคุณสมบัติ fontSize หรือส่งคืนขนาดฟอนต์ของข้อความ
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
fontSize | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติ fontSize:
object.style.fontSize
ตั้งค่าคุณสมบัติ fontSize:
object.style.fontSize = "value|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
xx-small x-small small medium large x-large xx-large |
Sets the size of the font to different fixed sizes, from xx-small to xx-large |
smaller | Decreases the font-size by one relative unit |
larger | Increases the font-size by one relative unit |
length | Defines the font-size in length units |
% | Sets the font-size to a % of the parent element's font size |
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.fontSize = listValue;
ตัวอย่าง
ส่งกลับขนาดตัวอักษรขององค์ประกอบ:
alert(document.getElementById("demo").style.fontSize);
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: แบบอักษร CSS
การอ้างอิง CSS: คุณสมบัติขนาดตัวอักษร
การอ้างอิง HTML DOM: คุณสมบัติแบบอักษร
❮ สไตล์วัตถุ