Propriedade CSS grid-template-columns
Exemplo
Faça um contêiner de grade de 4 colunas:
.grid-container {
display: grid;
grid-template-columns:
auto auto auto auto;
}
Definição e uso
A grid-template-columns
propriedade especifica o número (e as larguras) de colunas em um layout de grade.
Os valores são uma lista separada por espaços, onde cada valor especifica o tamanho da respectiva coluna.
Valor padrão: | Nenhum |
---|---|
Herdado: | não |
Animavel: | sim. Leia sobre animáveis |
Versão: | Módulo de Layout de Grade CSS Nível 1 |
Sintaxe JavaScript: | objeto .style.gridTemplateColumns="50px 50px 50px" |
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que oferece suporte total à propriedade.
Property | |||||
---|---|---|---|---|---|
grid-template-columns | 57 | 16 | 52 | 10 | 44 |
Sintaxe CSS
grid-template-columns: none|auto|max-content|min-content|length|initial|inherit;
Valores de propriedade
Value | Description | Play it |
---|---|---|
none | Default value. Columns are created if needed | |
auto | The size of the columns is determined by the size of the container and on the size of the content of the items in the column | |
max-content | Sets the size of each column to depend on the largest item in the column | |
min-content | Sets the size of each column to depend on the smallest item in the column | |
length | Sets the size of the columns, by using a legal length value. Read about length units | |
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
Faça um contêiner de grade de 4 colunas e especifique um tamanho para cada coluna:
.grid-container {
display: grid;
grid-template-columns:
30px 200px auto 100px;
}
Páginas relacionadas
Tutorial CSS: Layout de grade CSS
Referência CSS: a propriedade grid-template-rows
Referência CSS: A propriedade grid-template