Propiedad de cuadrícula CSS
Ejemplo
Haga un diseño de cuadrícula de tres columnas donde la primera fila tenga 150 px de alto:
.grid-container {
display: grid;
grid: 150px
/ auto auto auto;
}
Definición y uso
La grid
propiedad es una propiedad abreviada para:
- cuadrícula-plantilla-filas
- cuadrícula-plantilla-columnas
- cuadrícula-plantilla-áreas
- grid-auto-filas
- grid-auto-columnas
- grid-auto-flow
Valor por defecto: | ninguno ninguno ninguno auto auto fila |
---|---|
Heredado: | No |
Animable: | si, ver propiedades individuales . Leer sobre animable |
Versión: | Módulo de diseño de cuadrícula CSS Nivel 1 |
Sintaxis de JavaScript: | objeto .style.grid="250px / auto auto auto" |
Compatibilidad con navegador
Los números de la tabla especifican la primera versión del navegador que es totalmente compatible con la propiedad.
Property | |||||
---|---|---|---|---|---|
grid | 57 | 16 | 52 | 10 | 44 |
Sintaxis 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 propiedad
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 |
Más ejemplos
Ejemplo
Especifique dos filas, donde "elemento1" abarque las dos primeras columnas en las dos primeras filas (en un diseño de cuadrícula de cinco columnas):
.item1 {
grid-area: myArea;
}
.grid-container {
display: grid;
grid:
'myArea myArea . . .'
'myArea myArea . . .';
}
Ejemplo
Asigne un nombre a todos los elementos y cree una plantilla de página web lista para usar:
.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: contenedor de cuadrícula CSS
Referencia de CSS: la propiedad grid-template-areas
Referencia de CSS: la propiedad grid-template-rows
Referencia de CSS: la propiedad grid-template-columns
Referencia de CSS: la propiedad grid-auto-rows
Referencia CSS: la propiedad grid-auto-columns
Referencia de CSS: la propiedad grid-auto-flow
Referencia de CSS: la propiedad grid-row-gap
Referencia de CSS: la propiedad grid-column-gap