สไตล์textAlign Property
ตัวอย่าง
จัดกึ่งกลางข้อความในองค์ประกอบ:
document.getElementById("demo").style.textAlign = "center";
ความหมายและการใช้งาน
คุณสมบัติ textAlign ตั้งค่าหรือส่งคืนการจัดแนวข้อความในแนวนอนในองค์ประกอบระดับบล็อก
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
textAlign | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติ textAlign:
object.style.textAlign
ตั้งค่าคุณสมบัติ textAlign:
object.style.textAlign = "left|right|center|justify|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
left | Aligns the text to the left. This is default |
right | Aligns the text to the right |
center | Centers the text |
justify | The text is justified |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
รายละเอียดทางเทคนิค
ค่าเริ่มต้น: | ซ้าย |
---|---|
คืนมูลค่า: | สตริงที่แสดงถึงการจัดแนวข้อความในแนวนอนภายในองค์ประกอบ |
เวอร์ชัน CSS | CSS1 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ส่งคืนการจัดตำแหน่งข้อความขององค์ประกอบ:
alert(document.getElementById("demo").style.textAlign);
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: CSS Text
การอ้างอิง CSS: คุณสมบัติการจัดตำแหน่งข้อความ
❮ สไตล์วัตถุ