grid-area
grid-area is a CSS property used to specify the size and position of a grid item within a CSS grid layout. It is a shorthand property that combines the grid-row-start, grid-column-start, grid-row-end, and grid-column-end properties into a single value.
The grid-area property takes four values, in the order of grid-row-start, grid-column-start, grid-row-end, and grid-column-end. These values can be specified as either a number or a named grid line. For example:
.item {
grid-area: 2 / 1 / 4 / 4;
}
This would define an item that starts at row 2, column 1 and ends at row 4, column 4 within the grid.
Alternatively, the grid-area property can also take a name, which refers to a named grid area defined using the grid-template-areas property. For example:
.grid {
display: grid;
grid-template-areas:
"header header header"
"sidebar main main"
"footer footer footer";
}
.item {
grid-area: main;
}
This would define an item that spans the "main" grid area, which includes cells in rows 2 and 3, and columns 2 and 3.
原文地址: https://www.cveoy.top/t/topic/bKuy 著作权归作者所有。请勿转载和采集!