How does css implement vertical and horizontal center of images in an unknown wide-height div? cssdiv

Source: Internet
Author: User

How does css implement vertical and horizontal center of images in an unknown wide-height div? cssdiv

How does css implement vertical horizontal center of images in an unknown wide-height div:
In some cases, we may want to align an image vertically and horizontally in the div, but sometimes the size of the div is the position, the following code describes how to implement vertical and horizontal center of an image in this case.
The Code is as follows:
Instance 1:

<! DOCTYPE html>  

The above Code allows the image to be vertically and horizontally centered. Of course, the div size is fixed here, just for demonstration purposes. The unknown size can also be vertically and horizontally centered, the key code is as follows:

Display: table-cell; vertical-align: middle;

Some compatibility issues exist in the Code. Of course, this is not a problem because IE7 and IE6 browsers will soon be eliminated.

The original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 14774.

For more information, see: http://www.softwhy.com/divcss/

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.