CSS text-align-lastคุณสมบัติ
ตัวอย่าง
จัดแนวข้อความสุดท้ายในสาม <div> องค์ประกอบ:
div.a
{
text-align: justify; /* For Edge */
text-align-last: right;
}
div.b
{
text-align: justify; /* For Edge */
text-align-last: center;
}
div.c
{
text-align: justify; /* For Edge */
text-align-last: justify;
}
ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
คุณสมบัติtext-align-last
ระบุวิธีการจัดแนวบรรทัดสุดท้ายของข้อความ
โปรดสังเกตว่าtext-align-last
คุณสมบัติตั้งค่าการจัดตำแหน่งสำหรับบรรทัดสุดท้ายทั้งหมดภายในองค์ประกอบที่เลือก ดังนั้น หากคุณมี <div> ที่มีสามย่อหน้าอยู่ในนั้นtext-align-last
จะนำไปใช้กับบรรทัดสุดท้ายของแต่ละย่อหน้า หากต้องการใช้text-align-last
เฉพาะย่อหน้าสุดท้ายในคอนเทนเนอร์ คุณสามารถใช้ :last child ดูตัวอย่างด้านล่าง
หมายเหตุ:ใน Edge ก่อนหน้า 79 text-align-last
คุณสมบัตินี้ใช้ได้กับข้อความที่มี "text-align: justify" เท่านั้น
ค่าเริ่มต้น: | รถยนต์ |
---|---|
รับการถ่ายทอด: | ใช่ |
เคลื่อนไหวได้: | ไม่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSS3 |
ไวยากรณ์ JavaScript: | วัตถุ .style.textAlignLast="right" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Numbers ตามด้วย -moz- ระบุเวอร์ชันแรกที่ทำงานกับคำนำหน้า
Property | |||||
---|---|---|---|---|---|
text-align-last | 47.0 | 5.5* | 49.0 12.0 -moz- |
Not supported | 34.0 |
*ใน Internet Explorer 11 (และรุ่นก่อนหน้า) ไม่รองรับค่า "start" และ "end"
ไวยากรณ์ CSS
text-align-last: auto|left|right|center|justify|start|end|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description | Play it |
---|---|---|
auto | Default value. The last line is justified and aligned left | |
left | The last line is aligned to the left | |
right | The last line is aligned to the right | |
center | The last line is center-aligned | |
justify | The last line is justified as the rest of the lines | |
start | The last line is aligned at the beginning of the line (left if the text-direction is left-to-right, and right is the text-direction is right-to-left) | |
end | The last line is aligned at the end of the line (right if the text-direction is left-to-right, and left is the text-direction is right-to-left) | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ใช้ text-align-last เฉพาะบรรทัดสุดท้ายในคอนเทนเนอร์เท่านั้น:
div.b p:last-child {
text-align-last: center;
}
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: CSS Text
การอ้างอิง HTML DOM: คุณสมบัติ textAlignLast