CSS - rastereigenschap
Voorbeeld
Maak een rasterlay-out met drie kolommen waarbij de eerste rij 150px hoog is:
.grid-container {
display: grid;
grid: 150px
/ auto auto auto;
}
Definitie en gebruik
De grid
eigenschap is een steno-eigenschap voor:
- raster-sjabloon-rijen
- raster-sjabloon-kolommen
- raster-sjabloon-gebieden
- raster-auto-rijen
- raster-auto-kolommen
- grid-auto-flow
Standaardwaarde: | geen geen geen automatisch automatisch rij |
---|---|
geërfd: | Nee |
Animeerbaar: | ja, zie individuele eigenschappen . Lees over animeren |
Versie: | CSS-rasterlay-outmodule niveau 1 |
JavaScript-syntaxis: | object .style.grid="250px / auto auto auto" |
Browserondersteuning
De getallen in de tabel geven de eerste browserversie aan die de eigenschap volledig ondersteunt.
Property | |||||
---|---|---|---|---|---|
grid | 57 | 16 | 52 | 10 | 44 |
CSS-syntaxis
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;
Eigendomswaarden
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 |
Meer voorbeelden
Voorbeeld
Geef twee rijen op, waarbij "item1" de eerste twee kolommen in de eerste twee rijen omspant (in een rasterlay-out met vijf kolommen):
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid:
'myArea myArea . . .'
'myArea myArea . . .';
}
Voorbeeld
Geef alle items een naam en maak een kant-en-klaar webpaginasjabloon:
.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';
}
Gerelateerde pagina's
CSS-zelfstudie: CSS-rastercontainer
CSS-referentie: de eigenschap grid-template-areas
CSS-referentie: de eigenschap grid-template-rows
CSS-referentie: de eigenschap grid-template-columns
CSS-referentie: de eigenschap grid-auto-rows
CSS-referentie: de eigenschap grid-auto-columns
CSS-referentie: de eigenschap grid-auto-flow
CSS-referentie: de eigenschap grid-row-gap
CSS-referentie: de eigenschap grid-column-gap