Properti kisi CSS
Contoh
Buat tata letak kotak tiga kolom dengan tinggi baris pertama 150px:
.grid-container {
display: grid;
grid: 150px
/ auto auto auto;
}
Definisi dan Penggunaan
Properti grid
adalah properti singkatan untuk:
- grid-templat-baris
- kisi-templat-kolom
- grid-templat-area
- grid-auto-baris
- grid-auto-kolom
- jaringan-otomatis-aliran
Nilai bawaan: | tidak ada tidak ada tidak ada baris otomatis otomatis |
---|---|
Diwarisi: | tidak |
Animasi: | ya, lihat properti individu . Baca tentang animasi |
Versi: kapan: | Modul Tata Letak Grid CSS Level 1 |
Sintaks JavaScript: | objek .style.grid="250px / otomatis otomatis otomatis" |
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung properti.
Property | |||||
---|---|---|---|---|---|
grid | 57 | 16 | 52 | 10 | 44 |
Sintaks CSS
grid: none|grid-template-rows /
grid-template-columns|grid-template-areas|grid-template-rows
/ [grid-auto-flow] grid-auto-columns|[grid-auto-flow] grid-auto-rows / grid-template-columns|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 | |
grid-template-rows / grid-auto-columns | Specifies the size (height) of the rows, and the auto size of the columns | |
grid-auto-rows / grid-template-columns | Specifies the auto size of the rows, and sets the grid-template-columns property | |
grid-template-rows / grid-auto-flow grid-auto-columns | Specifies the size (height) of the rows, and how to place auto-placed items, and the auto size of the columns | |
grid-auto-flow grid-auto-rows / grid-template-columns | Specifies how to place auto-placed items, and the auto size of the rows, and sets the grid-template-columns property | |
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:
'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:
'header header header header header'
'menu main main main right right'
'menu footer footer
footer footer';
}
Halaman Terkait
Tutorial CSS: Wadah Kotak CSS
Referensi CSS: Properti grid-template- areas
Referensi CSS: Properti grid-template- rows
Referensi CSS: Properti grid-template- columns
Referensi CSS: Properti grid-auto- rows
Referensi CSS: Properti grid-auto - columns
Referensi CSS: Properti grid-auto- flow
Referensi CSS: Properti grid-row- gap
Referensi CSS: Properti grid-column - gap