1. grid-template #

Created Thursday 03 September 2020

Syntax and usage #

.container 
{
	display: grid;
	grid-template-columns: 50px 50px;
	/* The grid will have two columns of width 50px*/
}

Units for row/col size #

There are 4 units (values):

  1. fr - fraction of the available(remaining) space
  2. auto - takes the space as per content
  3. px or em
  4. % - percentage of the container dimension
  5. min-content
  6. max-content

With repeat #

repeat #

.container
{
  grid-template-columns: repeat(2, 1fr, auto) 2fr;
  /* same as 1fr auto 1fr auto 2fr */
}

minmax #

Gives two values at the same time, minmax(smaller, greater)

repeat(auto-fill) #

Don’t need to specify the number of repetitions.

e.g This will change the push the other items down if size is less.

.container 
{
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
}

repeat(auto-fit) #

value is similar to auto-fill but it does not keep any empty space. Expands the items accordingly.