Compatible with images in various browsers vertical center CSS Solution

Source: Internet
Author: User

1, by adding a no semantic image to solve the vertical center of the image CSS, compatible with a variety of Ie6,ie7, Firefox, Google and other browsers.  <style>. itm{border:2px solid #ccc; width:160px;height:160px;text-align:center;}  . blank{width:0;height:160px;}  . ITM Img{vertical-align:middle;} </style> <div class= "ITM" >  <a Href= "" ></a> </div> 2,          Use hack to center the picture vertically <style>. Box {/*/non IE mainstream browsers recognize the vertical centering method */Display:table-cell;           Vertical-align:middle;           /* Set Horizontal Center */text-align:center;          /* for IE hack */*display:block; *font-size:175px;/* about a height of 0.873,200*0.873 about 175*/*font-family:arial;/* to prevent utf-8 failures caused by non-hack, such as GBK code */Widt          h:200px;          height:200px;  border:1px solid #eee;  }. Box img {/* Set picture vertically centered */vertical-align:middle; } </style> <div class= "box" >  </div>   

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.