Css style setting height undefined text vertical center

Source: Internet
Author: User

Using css to implement vertical text center is easier for browsers that support display: table. You only need to set the external layer div to table and the inner layer div to table-cell, set the vertical center of the text. However, for IE6/7, display: table is not supported. You can only use the location method for processing. The outer div gives a positioning. The middle div is absolutely positioned relative to the outer layer. The top is 50%, the inner span is relatively positioned, and the top is-50%. The content is vertically centered through the positioning of plus and minus 50%.

Related DEMO code (no matter how div1 height is changed, the content can be vertically centered with no limit to the number of lines ):

In ie, vertical center IE6/7 uses the positioning relationship to vertical center, and IE8/9 uses the display: table and display: table-cell

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.