CSS กริดเทมเพลตคอลัมน์คุณสมบัติ
ตัวอย่าง
สร้างคอนเทนเนอร์กริด 4 คอลัมน์:
.grid-container {
display: grid;
grid-template-columns:
auto auto auto auto;
}
ความหมายและการใช้งาน
คุณสมบัติgrid-template-columns
ระบุจำนวน (และความกว้าง) ของคอลัมน์ในรูปแบบกริด
ค่าต่างๆ เป็นรายการที่คั่นด้วยช่องว่าง โดยที่แต่ละค่าจะระบุขนาดของคอลัมน์ที่เกี่ยวข้อง
ค่าเริ่มต้น: | ไม่มี |
---|---|
รับการถ่ายทอด: | ไม่ |
เคลื่อนไหวได้: | ใช่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSS Grid Layout Module ระดับ 1 |
ไวยากรณ์ JavaScript: | วัตถุ .style.gridTemplateColumns="50px 50px 50px" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
grid-template-columns | 57 | 16 | 52 | 10 | 44 |
ไวยากรณ์ CSS
grid-template-columns: none|auto|max-content|min-content|length|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description | Play it |
---|---|---|
none | Default value. Columns are created if needed | |
auto | The size of the columns is determined by the size of the container and on the size of the content of the items in the column | |
max-content | Sets the size of each column to depend on the largest item in the column | |
min-content | Sets the size of each column to depend on the smallest item in the column | |
length | Sets the size of the columns, by using a legal length value. Read about length units | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
สร้างคอนเทนเนอร์กริด 4 คอลัมน์ และระบุขนาดสำหรับแต่ละคอลัมน์:
.grid-container {
display: grid;
grid-template-columns:
30px 200px auto 100px;
}
หน้าที่เกี่ยวข้อง
บทช่วยสอน CSS: เค้าโครงตาราง CSS
การอ้างอิง CSS: คุณสมบัติgrid -template-rows
การอ้างอิง CSS: คุณสมบัติเทมเพลตกริด