An image of unknown size (but its height and width are smaller than px) is centered horizontally and vertically in a PX square container using pure CSS.

Source: Internet
Author: User
Div {width: 200px; Height: 200px; Border: 1px solid #666; display: Table-cell; Vertical-align: middle; text-align: center; * float: left; // here float: Left is used to be compatible with IE Supporting Left and Right Arrangement} Div IMG {margin-top: expression (100-this.height/2 ); // use vertical-align: middle; instead if you do not want to arrange the left and right sides. We recommend that you use expressions here. Although the performance is poor, IE6 is just like this. No way}

Of course, there may be other good methods. I hope the masses of money can attack the city to give you good dishes.

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.