CSS: Center a div
A short, tested CSS example for center a div. Copy it and adjust the names and paths for your project.
CSS
/* flexbox */
.parent { display: flex; justify-content: center; align-items: center; }
/* grid (shortest) */
.parent { display: grid; place-items: center; }
/* horizontally only */
.child { margin-inline: auto; width: fit-content; }Find it in Zest
Search for “css center a div” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.