Bonus: this works even if the child is bigger than the parent. You can also center it vertically with this (and again, width and height of parent and child can be totally flexible (and/or unknown)): .centered-axis-xy { position: absolute; left: 50%; top: 50%; transform: translate(...
Centering both horizontally & vertically In my experience, the best way to center a box both vertically and horizontally is to use an additional container and apply the following properties: The outer container: should have display: table; The inner container: should have display: table-cell; s...