Flexbox

Line items up in a row or column and share the space between them.

Use flexbox when items sit along one direction, such as a navigation bar, a row of buttons or a card footer. Set display: flex on the parent, then control the children from there.

Edit the CSS
Preview
PropertyWhat it does
flex-directionrow (default) or column
justify-contentSpacing along the main direction: center, space-between
align-itemsAlignment across it: center, stretch
flex-wrap: wrapLets items move to the next line
gapSpace between items, with no margin hacks
flex: 1On a child: take the free space

Centre anything

CSS
.centre {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}
โ† Display and positionCSS Grid โ†’