Proprietà griglia CSS
Esempio
Crea un layout a griglia a tre colonne in cui la prima riga è alta 150 px:
.grid-container {
display: grid;
grid: 150px
/ auto auto auto;
}
Definizione e utilizzo
La grid
proprietà è una proprietà abbreviata per:
- righe-modello-griglia
- colonne-modello-griglia
- aree-modello-griglia
- righe automatiche della griglia
- colonne grid-auto
- flusso automatico della griglia
Valore di default: | nessuno nessuno nessuno riga automatica automatica |
---|---|
Ereditato: | no |
Animabile: | sì, vedi singole proprietà . Leggi su animabile |
Versione: | Modulo layout griglia CSS Livello 1 |
sintassi JavaScript: | oggetto .style.grid="250px / auto auto auto" |
Supporto browser
I numeri nella tabella specificano la prima versione del browser che supporta completamente la proprietà.
Property | |||||
---|---|---|---|---|---|
grid | 57 | 16 | 52 | 10 | 44 |
Sintassi 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;
Valori di proprietà
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 |
Altri esempi
Esempio
Specificare due righe, dove "item1" si estende sulle prime due colonne nelle prime due righe (in un layout a griglia a cinque colonne):
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid:
'myArea myArea . . .'
'myArea myArea . . .';
}
Esempio
Assegna un nome a tutti gli elementi e crea un modello di pagina Web pronto per l'uso:
.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';
}
Pagine correlate
Esercitazione CSS: contenitore della griglia CSS
Riferimento CSS: la proprietà grid-template-areas
Riferimento CSS: la proprietà grid-template-rows
Riferimento CSS: la proprietà grid-template-columns
Riferimento CSS: la proprietà grid-auto-rows
Riferimento CSS: la proprietà grid-auto-columns
Riferimento CSS: la proprietà grid-auto-flow
Riferimento CSS: la proprietà grid-row-gap
Riferimento CSS: la proprietà grid-column-gap