Propriété de la grille CSS
Exemple
Créez une disposition en grille à trois colonnes où la première ligne mesure 150 pixels de haut :
.grid-container {
display: grid;
grid: 150px
/ auto auto auto;
}
Définition et utilisation
La grid
propriété est une propriété abrégée pour :
- grille-modèle-lignes
- grille-modèle-colonnes
- zones de modèle de grille
- grille-auto-lignes
- grille-auto-colonnes
- grille-flux automatique
Valeur par défaut: | aucun aucun aucun auto ligne automatique |
---|---|
Hérité: | non |
Animable : | oui, voir propriétés individuelles . En savoir plus sur l'animation |
Version: | Module de disposition de grille CSS niveau 1 |
Syntaxe JavaScript : | objet .style.grid="250px / auto auto auto" |
Prise en charge du navigateur
Les nombres dans le tableau indiquent la première version du navigateur qui prend entièrement en charge la propriété.
Property | |||||
---|---|---|---|---|---|
grid | 57 | 16 | 52 | 10 | 44 |
Syntaxe 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;
Valeurs de propriété
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 |
Plus d'exemples
Exemple
Spécifiez deux lignes, où "item1" s'étend sur les deux premières colonnes des deux premières lignes (dans une disposition en grille à cinq colonnes) :
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid:
'myArea myArea . . .'
'myArea myArea . . .';
}
Exemple
Nommez tous les éléments et créez un modèle de page Web prêt à l'emploi :
.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';
}
Pages connexes
Tutoriel CSS : Conteneur de grille CSS
Référence CSS : La propriété grid-template-areas
Référence CSS : La propriété grid-template-rows
Référence CSS : La propriété grid-template-columns
Référence CSS : La propriété grid-auto-rows
Référence CSS : La propriété grid-auto-columns
Référence CSS : La propriété grid-auto-flow
Référence CSS : La propriété grid-row-gap
Référence CSS : La propriété grid-column-gap