Propriedade de grade CSS
Exemplo
Faça um layout de grade de três colunas em que a primeira linha tenha 150px de altura:
.grid-container {
display: grid;
grid: 150px
/ auto auto auto;
}
Definição e uso
A grid
propriedade é uma propriedade abreviada para:
- grid-template-rows
- grid-template-colunas
- grid-template-áreas
- grid-auto-rows
- colunas-auto-grade
- grid-auto-flow
Valor padrão: | nenhum nenhum nenhum auto linha automática |
---|---|
Herdado: | não |
Animavel: | sim, consulte propriedades individuais . Leia sobre animáveis |
Versão: | Módulo de Layout de Grade CSS Nível 1 |
Sintaxe JavaScript: | object .style.grid="250px / auto auto auto" |
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que oferece suporte total à propriedade.
Property | |||||
---|---|---|---|---|---|
grid | 57 | 16 | 52 | 10 | 44 |
Sintaxe 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;
Valores de propriedade
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 |
Mais exemplos
Exemplo
Especifique duas linhas, onde "item1" abrange as duas primeiras colunas nas duas primeiras linhas (em um layout de grade de cinco colunas):
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid:
'myArea myArea . . .'
'myArea myArea . . .';
}
Exemplo
Nomeie todos os itens e crie um modelo de página da Web pronto para 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';
}
Páginas relacionadas
Tutorial de CSS: Contêiner de Grade CSS
Referência CSS: a propriedade grid-template-areas
Referência CSS: A propriedade grid-template-rows
Referência CSS: A propriedade grid-template-columns
Referência CSS: A propriedade grid-auto-rows
Referência CSS: a propriedade grid-auto-columns
Referência CSS: a propriedade grid-auto-flow
Referência CSS: a propriedade grid-row-gap
Referência CSS: a propriedade grid-column-gap