คุณสมบัติการจัดตำแหน่งข้อความ CSS
ตัวอย่าง
ตั้งค่าการจัดตำแหน่งข้อความสำหรับองค์ประกอบ <div> ที่แตกต่างกัน:
div.a {
text-align: center;
}
div.b {
text-align: left;
}
div.c {
text-align: right;
}
div.c {
text-align:
justify;
}
ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
คุณสมบัติระบุ การtext-align
จัดแนวข้อความในแนวนอนในองค์ประกอบ
ค่าเริ่มต้น: | ซ้ายถ้าทิศทางคือ ltr และขวาถ้าทิศทางคือ rtl |
---|---|
รับการถ่ายทอด: | ใช่ |
เคลื่อนไหวได้: | ไม่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSS1 |
ไวยากรณ์ JavaScript: | วัตถุ .style.textAlign="right" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
text-align | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
ไวยากรณ์ CSS
text-align: left|right|center|justify|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description | Play it |
---|---|---|
left | Aligns the text to the left | |
right | Aligns the text to the right | |
center | Centers the text | |
justify | Stretches the lines so that each line has equal width (like in newspapers and magazines) | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ตัวอย่างการจัดข้อความอื่น:
h1 {
text-align: center;
}
p.date {
text-align: right;
}
p.main {
text-align: justify;
}
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: CSS Text
การอ้างอิง HTML DOM: textAlign คุณสมบัติ