transform: translate(-50%, 50%)
Above properties, the elements will own the upper left corner as the origin, moving up 50% left their length and width, respectively, so that it is centered position.
And a negative margin-left and margin-top to achieve a different center, margin-left and margin-top width must know itself is high, and may be centered translate without knowing the width and height of the case.