Properti kolom-templat-grid CSS
Contoh
Buat wadah kotak 4 kolom:
.grid-container {
display: grid;
grid-template-columns:
auto auto auto auto;
}
Definisi dan Penggunaan
Properti grid-template-columns
menentukan jumlah (dan lebar) kolom dalam tata letak kisi.
Nilai adalah daftar yang dipisahkan spasi, di mana setiap nilai menentukan ukuran kolom masing-masing.
Nilai bawaan: | tidak ada |
---|---|
Diwarisi: | tidak |
Animasi: | Ya. Baca tentang animasi |
Versi: kapan: | Modul Tata Letak Grid CSS Level 1 |
Sintaks JavaScript: | objek .style.gridTemplateColumns="50px 50px 50px" |
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung properti.
Property | |||||
---|---|---|---|---|---|
grid-template-columns | 57 | 16 | 52 | 10 | 44 |
Sintaks CSS
grid-template-columns: none|auto|max-content|min-content|length|initial|inherit;
Nilai properti
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 |
Lebih Banyak Contoh
Contoh
Buat wadah kotak 4 kolom, dan tentukan ukuran untuk setiap kolom:
.grid-container {
display: grid;
grid-template-columns:
30px 200px auto 100px;
}
Halaman Terkait
Tutorial CSS: Tata Letak Kotak CSS
Referensi CSS: Properti grid-template- rows
Referensi CSS: Properti template-grid