Centering with CSS Grid

suggest change

Grid can center an item on both axes without table-layout emulation:

<div class="stage">
  <div class="item">Centered</div>
</div>
.stage {
  min-block-size: 12rem;
  display: grid;
  place-items: center;
}

place-items: center is shorthand for align-items: center and justify-items: center. Use min-block-size instead of a fixed height when the container should be able to grow with its content.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents