moves / css / center anything

Center anything

Flexbox is the shortest path to both-axis centering. `place-items: center` on a grid does the same in one line if the parent has a height.

#flexbox#grid#layout#centering
css

.parent {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

/* grid one-liner */
.parent-grid {
  display: grid;
  place-items: center;
  min-height: 100dvh;
}

Related

WWADD — Choose the tool. Make the move. Build the stack.

FREE REFERENCE · NO LOGINCONTACTPRIVACYTERMS