Properti templat kisi CSS
Contoh
Buat tata letak kotak tiga kolom dengan tinggi baris pertama 150px:
.grid-container {
display: grid;
grid-template: 150px
/ auto auto auto;
}
Definisi dan Penggunaan
Properti grid-template
adalah properti singkatan untuk properti berikut:
Nilai bawaan: | tidak ada tidak ada |
---|---|
Diwarisi: | tidak |
Animasi: | Ya. Baca tentang animasi |
Versi: kapan: | Modul Tata Letak Grid CSS Level 1 |
Sintaks JavaScript: | objek .style.gridTemplate="250px / otomatis otomatis" |
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung properti.
Property | |||||
---|---|---|---|---|---|
grid-template | 57 | 16 | 52 | 10 | 44 |
Sintaks CSS
grid-template: none|grid-template-rows /
grid-template-columns|grid-template-areas|initial|inherit;
Nilai properti
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 |
Lebih Banyak Contoh
Contoh
Tentukan dua baris, di mana "item1" mencakup dua kolom pertama di dua baris pertama (dalam tata letak kisi lima kolom):
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid-template:
'myArea myArea . . .'
'myArea myArea . . .';
}
Contoh
Beri nama semua item, dan buat templat halaman web siap pakai:
.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';
}
Halaman Terkait
Tutorial CSS: Item Kotak CSS
Referensi CSS: Properti area kisi
Referensi CSS: Properti grid-template- rows
Referensi CSS: Properti grid-template- columns
Referensi CSS: Properti grid-template- areas