Pure CSS for text and image horizontal Vertical Center

Source: Internet
Author: User

1, picture and text horizontal center only need to add text-align:center can;

2, single-line text vertical center, height is equal to row height;

3, multi-line text and picture Vertical center:

Need to nest two layers outside, the first layer to set the fixed height, and display:table; second layer plus Display:table-cell; Vertical-align:middle can be implemented (IE7 and the following are not valid)

4, Picture vertical center of another scheme, compatible with any browser:

Nesting a layer outside the picture, set the height Display:table-cell; Vertical-align:middle; *font-size:175px, (set *font-size to be compatible with IE6, 7, generally set to height and font size ratio of 1.14), and finally add Vertical-align:middle, vertical centering possible

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.