Files
30-seconds-of-code/snippets/css/s/flexbox-centering.md
2023-05-07 16:07:29 +03:00

607 B

title, type, language, tags, cover, dateModified
title type language tags cover dateModified
Flexbox centering snippet css
layout
basket-paper 2020-12-30T15:37:37+02:00

Horizontally and vertically centers a child element within a parent element using flexbox.

  • Use display: flex to create a flexbox layout.
  • Use justify-content: center to center the child horizontally.
  • Use align-items: center to center the child vertically.
<div class="flexbox-centering">
  <div>Centered content.</div>
</div>
.flexbox-centering {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
}