CSS grid-column
CSS grid-column
The grid-column property in CSS is used to specify the size of columns in a grid layout. It allows you to control the size and position of grid columns within a grid container.
Syntax:
grid-column: grid-start / grid-end
{grid-column: 1 / span 2;}
{grid-column: 1 / span 3;}
{grid-column: 2 / span 3;}
{grid-column: 2 / span 4;}
{grid-column: 3 / span 2;}
The grid-start and grid-end values specify the starting and ending positions of the grid column, which can be either a line number, a name, or a span of multiple lines.
Examples:
In this example, we have a grid container with 3 columns. The first div element spans from the first column to the third column using grid-column: 1 / 3;, and the second div element spans from the second column to the fourth column using grid-column: 2 / 4;.
You can also use span to specify the number of columns the grid item should span:
This example shows a grid item that starts from the second column and spans 2 columns using grid-column: 2 / span 2;.