คุณสมบัติCSS flex-direction
ตัวอย่าง
กำหนดทิศทางของรายการที่ยืดหยุ่นภายในองค์ประกอบ <div> ในลำดับย้อนกลับ:
div
{
display: flex;
flex-direction: row-reverse;
}
เคล็ดลับ:ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
คุณสมบัติflex-direction
ระบุทิศทางของรายการที่ยืดหยุ่น
หมายเหตุ:หากองค์ประกอบไม่ใช่รายการที่ยืดหยุ่นflex-direction
คุณสมบัติจะไม่มีผล
ค่าเริ่มต้น: | แถว |
---|---|
รับการถ่ายทอด: | ไม่ |
เคลื่อนไหวได้: | ไม่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSS3 |
ไวยากรณ์ JavaScript: | วัตถุ .style.flexDirection="column-reverse" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
ตัวเลขตามด้วย -webkit- หรือ -moz- ระบุเวอร์ชันแรกที่ทำงานกับคำนำหน้า
Property | |||||
---|---|---|---|---|---|
flex-direction | 29.0 21.0 -webkit- |
11.0 | 28.0 18.0 -moz- |
9.0 6.1 -webkit- |
17.0 |
ไวยากรณ์ CSS
flex-direction: row|row-reverse|column|column-reverse|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description | Play it |
---|---|---|
row | Default value. The flexible items are displayed horizontally, as a row | |
row-reverse | Same as row, but in reverse order | |
column | The flexible items are displayed vertically, as a column | |
column-reverse | Same as column, but in reverse order | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ใช้flex-direction
ร่วมกับคิวรี่สื่อเพื่อสร้างเลย์เอาต์ที่แตกต่างกันสำหรับขนาดหน้าจอ/อุปกรณ์ต่างๆ:
.flex-container {
display: flex;
flex-direction: row;
}
/*
Responsive layout - makes a one column layout instead of a two-column layout
*/
@media (max-width: 800px) {
.flex-container {
flex-direction: column;
}
}
หน้าที่เกี่ยวข้อง
บทช่วยสอน CSS: CSS Flexible Box
การอ้างอิง CSS: คุณสมบัติ flex-flow
การอ้างอิง CSS: คุณสมบัติ flex-wrap
การอ้างอิง CSS: คุณสมบัติ flex
การอ้างอิง CSS: คุณสมบัติ flex-grow
การอ้างอิง CSS: คุณสมบัติ flex-shrink
การอ้างอิง CSS: คุณสมบัติพื้นฐานแบบยืดหยุ่น
การอ้างอิง HTML DOM: คุณสมบัติ flexDirection