Grid by Example

Everything you need to learn CSS Grid Layout

Defining a Grid

To define a Grid use display:grid or display:inline-grid on the parent element. You can then create a grid using the grid-template-columns and grid-template-rows properties.

I am using the grid-gap property to create a gap between my columns and rows of 10px. This property is a shorthand for grid-column-gap and grid-row-gap so you can set these values individually.

All direct children of the parent now become grid items and the auto-placement algorithm lays them out, one in each grid cell. Creating extra rows as needed.

Read the specification | View example as full page

See the Pen Grid by Example 1: Defining a Grid by rachelandrew (@rachelandrew) on CodePen.