Zest.

CSS: Absolute centering

A short, tested CSS example for absolute centering. Copy it and adjust the names and paths for your project.

CSS
.modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(90vw, 480px);
  height: fit-content;
}

Find it in Zest

Search for “css absolute centering” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More CSS examples

All CSS examples