When talking about this question, someone may ask if CSS does not have the vertical-align attribute to set vertical center? Even some Browsers Do not support CSS hack technology! So here I have to say a few more words,
CSS does have the vertical-align attribute, but it takes effect only for elements with the valign attribute in (x) HTML elements, for example, <TD>, <TH>, and <caption> in table elements, but elements like <div> and <span> do not have the valign feature, therefore, using vertical-align does not work for them.
CSS webpage layout Div horizontal center methods 1. Single Row vertical center if a container contains only one line of text, it is relatively easy to center it, we only need to set the actual height of the line to be equal to the line-height of the row. For example: div {Height: 25px; line-Height: 25px; overflow: hidden;} This code is very simple, and overflow is used later: the purpose of the Hidden setting is to prevent the content from exceeding the container or generating automatic line breaks, so that the vertical center effect cannot be reached. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml">