CSS grid-template-columns Eigenschap
Voorbeeld
Maak een rastercontainer met 4 kolommen:
.grid-container {
display: grid;
grid-template-columns:
auto auto auto auto;
}
Definitie en gebruik
De grid-template-columns
eigenschap specificeert het aantal (en de breedtes) van kolommen in een rasterlay-out.
De waarden zijn een door spaties gescheiden lijst, waarbij elke waarde de grootte van de respectieve kolom aangeeft.
Standaardwaarde: | geen |
---|---|
geërfd: | Nee |
Animeerbaar: | Ja. Lees over animeren |
Versie: | CSS-rasterlay-outmodule niveau 1 |
JavaScript-syntaxis: | object .style.gridTemplateColumns="50px 50px 50px" |
Browserondersteuning
De getallen in de tabel geven de eerste browserversie aan die de eigenschap volledig ondersteunt.
Property | |||||
---|---|---|---|---|---|
grid-template-columns | 57 | 16 | 52 | 10 | 44 |
CSS-syntaxis
grid-template-columns: none|auto|max-content|min-content|length|initial|inherit;
Eigendomswaarden
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 |
Meer voorbeelden
Voorbeeld
Maak een rastercontainer met 4 kolommen en specificeer een grootte voor elke kolom:
.grid-container {
display: grid;
grid-template-columns:
30px 200px auto 100px;
}
Gerelateerde pagina's
CSS-zelfstudie: CSS-rasterlay-out
CSS-referentie: de eigenschap grid-template-rows
CSS-referentie: de eigenschap grid-template