Building a grid
Alignment
Grid alignment works on two levels: items inside their cells, and tracks inside the container.
Aligning items inside their cells #
In the Alignment section:
| Setting | Direction | Options |
|---|---|---|
justify-items | Horizontal | start, end, center, stretch |
align-items | Vertical | start, end, center, stretch, baseline |
With stretch (the default), items fill their area. With any other value, items shrink to their content, which you will see in the preview.
Aligning the tracks inside the container #
| Setting | Direction | Options |
|---|---|---|
justify-content | Horizontal | start, end, center, stretch, space-between, space-around, space-evenly |
align-content | Vertical | start, end, center, stretch, space-between, space-around, space-evenly |
These only have a visible effect when the tracks are smaller than the container, for example fixed px columns in a wide container, or rows in a container with a set height. With fr tracks there is no free space left to distribute.
Aligning a single item #
Select an item and use Justify self and Align self under Selected item. These override the grid's setting for that item only, and are written into its rule:
.main {
grid-column: 2;
grid-row: 2;
justify-self: center;
align-self: start;
}
Not set #
Not set (or Inherit from grid for items) leaves the property out of the CSS, so the browser default applies. GridFlow only writes what you change.