CSS grid-template-columns Właściwość
Przykład
Utwórz kontener z siatką 4 kolumn:
.grid-container {
display: grid;
grid-template-columns:
auto auto auto auto;
}
Definicja i użycie
Właściwość grid-template-columns
określa liczbę (i szerokości) kolumn w układzie siatki.
Wartości są listą oddzieloną spacjami, gdzie każda wartość określa rozmiar odpowiedniej kolumny.
Domyślna wartość: | Żaden |
---|---|
Dziedziczny: | nie |
Animowalny: | tak. Przeczytaj o animacji |
Wersja: | Moduł układu siatki CSS, poziom 1 |
Składnia JavaScript: | obiekt .style.gridTemplateColumns="50px 50px 50px" |
Obsługa przeglądarki
Liczby w tabeli określają pierwszą wersję przeglądarki, która w pełni obsługuje tę właściwość.
Property | |||||
---|---|---|---|---|---|
grid-template-columns | 57 | 16 | 52 | 10 | 44 |
Składnia CSS
grid-template-columns: none|auto|max-content|min-content|length|initial|inherit;
Wartości nieruchomości
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 |
Więcej przykładów
Przykład
Utwórz kontener siatki z 4 kolumnami i określ rozmiar każdej kolumny:
.grid-container {
display: grid;
grid-template-columns:
30px 200px auto 100px;
}
Powiązane strony
Samouczek CSS: układ siatki CSS
CSS Reference: Właściwość grid -template-rows
CSS Reference: Właściwość grid -template