I just forwarded a post about vertical alignment of divs. It’s easy to understand after reading the picture
Use absolute position: absolute;
and then set top and left to 50.top:50%;left:50%;
Because at this time the browser The position shown by the green dot in the picture will be the default actual position. To center the content, set margin-left and margin-top to negative half width and half width respectively.
Anyway, the effect is achieved...it still feels a bit deceptive haha.
expression is not supported in FF, so it is best to use JS to control dynamic assignment.