Home > Article > Web Front-end > CSS solves unknown height vertical centering_CSS/HTML
Although there is CSS vertical-align feature, it cannot effectively solve the vertical centering problem of unknown height (when there is text or image of unknown height in a DIV tag).
For standard browsers such as Mozilla, Opera, Safari, etc., you can set the display mode of the parent element to TABLE (display: table;) and the internal child elements to table-cell (display: table-cell ), using the vertical-align feature to vertically center it, but non-standard browsers do not support it.
Non-standard browsers can only set the child element to be 50% from the top, and then add an element inside to offset it by -50% from the top.