Vlastnost mřížky CSS
Příklad
Vytvořte třísloupcové rozvržení mřížky, kde je první řádek vysoký 150 pixelů:
.grid-container {
display: grid;
grid: 150px
/ auto auto auto;
}
Definice a použití
Vlastnost grid
je zkrácená vlastnost pro:
- grid-template-rows
- mřížka-šablona-sloupce
- oblasti mřížky-šablony
- grid-auto-rows
- mřížka-automatické-sloupce
- mřížka-automatický tok
Výchozí hodnota: | žádný žádný žádný automatický automatický řádek |
---|---|
Zděděno: | Ne |
Animovatelné: | ano, viz jednotlivé vlastnosti . Přečtěte si o tématu Animable |
Verze: | Modul rozložení mřížky CSS, úroveň 1 |
Syntaxe JavaScriptu: | object .style.grid="250px / auto auto auto" |
Podpora prohlížeče
Čísla v tabulce určují první verzi prohlížeče, která plně podporuje vlastnost.
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;
Hodnoty vlastností
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 |
Další příklady
Příklad
Zadejte dva řádky, kde "položka1" zahrnuje první dva sloupce v prvních dvou řádcích (v pětisloupcovém uspořádání mřížky):
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid:
'myArea myArea . . .'
'myArea myArea . . .';
}
Příklad
Pojmenujte všechny položky a vytvořte šablonu webové stránky připravenou k použití:
.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';
}
Související stránky
CSS kurz: CSS Grid Container
CSS Reference: Vlastnost grid -template-areas
CSS Reference: Vlastnost grid -template-rows
CSS Reference: Vlastnost grid -template-columns
CSS Reference: Vlastnost grid -auto-rows
CSS Reference: Vlastnost grid -auto-columns
CSS Reference: Vlastnost grid -auto-flow
CSS Reference: Vlastnost grid -row-gap
CSS Reference: Vlastnost grid -column-gap