grid auto columns code example

Example 1: grid auto columns

grid-template-columns: repeat( auto-fit, minmax(250px, 1fr) );

Example 2: autofit grid css

.grid {
   display: grid;
  grid-template-columns: repeat(auto-fit, 1fr);
}

Example 3: grid repeating auto columns

/* To achieve wrapping, we can use the auto-fit or auto-fill keywords. */

grid-template-columns: repeat( auto-fit, minmax(250px, 1fr) );

Example 4: css grid repeat

repeat(/*Number of repeats*/, /*Code to be repeated*/)

.gridContainer {
	grid-template-columns: repeat(4, 100px); /*Creates 4 columns, each 100px in width*/
	grid-template-rows: repeat(2, 250px); /*Creates 2 rows, each 250px in height*/
}

Tags:

Misc Example