คุณสมบัติเทมเพลตกริด CSS
ตัวอย่าง
สร้างเค้าโครงตารางสามคอลัมน์โดยที่แถวแรกสูง 150px:
.grid-container {
display: grid;
grid-template: 150px
/ auto auto auto;
}
ความหมายและการใช้งาน
ทรัพย์สิน เป็นgrid-template
ทรัพย์สินชวเลขสำหรับคุณสมบัติต่อไปนี้:
ค่าเริ่มต้น: | ไม่มี ไม่มี ไม่มี |
---|---|
รับการถ่ายทอด: | ไม่ |
เคลื่อนไหวได้: | ใช่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSS Grid Layout Module ระดับ 1 |
ไวยากรณ์ JavaScript: | วัตถุ .style.gridTemplate="250px / auto auto" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
grid-template | 57 | 16 | 52 | 10 | 44 |
ไวยากรณ์ CSS
grid-template: none|grid-template-rows /
grid-template-columns|grid-template-areas|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description | Play it |
---|---|---|
none | Default value. No specific sizing of the columns or rows | |
grid-template rows / grid-template-columns | Specifies the size(s) of the columns and rows | |
grid-template-areas | Specifies the grid layout using named items | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ระบุสองแถว โดยที่ "item1" ครอบคลุมสองคอลัมน์แรกในสองแถวแรก (ในรูปแบบตารางห้าคอลัมน์):
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid-template:
'myArea myArea . . .'
'myArea myArea . . .';
}
ตัวอย่าง
ตั้งชื่อรายการทั้งหมด และสร้างเทมเพลตหน้าเว็บที่พร้อมใช้งาน:
.item1 { grid-area: header; }
.item2 { grid-area:
menu; }
.item3 { grid-area:
main; }
.item4 { grid-area:
right; }
.item5 { grid-area:
footer; }
.grid-container {
display: grid;
grid-template:
'header header header header header header'
'menu main main main right right'
'menu footer footer
footer footer footer';
}
หน้าที่เกี่ยวข้อง
บทช่วยสอน CSS: CSS Grid Item
การอ้างอิง CSS: คุณสมบัติพื้นที่กริด
การอ้างอิง CSS: คุณสมบัติgrid -template-rows
การอ้างอิง CSS: คุณสมบัติgrid -template-columns
การอ้างอิง CSS: คุณสมบัติgrid -template-areas