Skip to content

viveksrao/built-with-css-grid

Repository files navigation

Building Layouts with the CSS Grid

First you define a grid on a parent container by using the display property and setting the value to either grid or inline-grid. Next the rows and columns inside of it are referred to as child items and you define those rows and columns with grid-template-rows and grid-template-columns properties. The units you can use for these are fixed units such as Pixels (px) and flexible units such as Percentages (%) or Fractions (fr). You can adjust the space between rows and columns by using these properties – grid-column-gap, grid-row-gap or the shorthand property grid-gap. Now for aligning grid items along the row axis you can use these 2 properties – justify-items which aligns all of the rows and justify-self which aligns a single row. For aligning grid items on the column axis we use the align-items and align-self properties. Now all 4 of these properties accept the same potential values of start, end, center and stretch. For the times in which you need to align the entire grid itself you use the justify-content property for aligning on the row axis and the align-content property to align the grid on the column axis. Both of these properties accept the same potential values of start, end, center, stretch, space-between, space-around and space-evenly.

Line-based Placement

  • grid-column-start and grid-row-start specify the line where the item begins
  • grid-column-end and grid-row-end specify the line where the item ends

Grid Resources

About

Examples of layouts built using the new CSS Grid.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published