CSS Position Picture Vertical Center Example

Source: Internet
Author: User
Tip: You can modify some of the code before running

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "><br/> <ptml xmlns=" http://www.w3.org/1999/xhtml "><br/> <pead><br/> <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/></p> <style type=" Text/css "> miao{width:170px;height:100px;display:table; Text-align:center;border:solid 1px red; . Miao span{display:table-cell;vertical-align:middle;border:solid 1px blue; Miao span img{border:dashed 1px green; </style> <p><!--[if LTE IE 7]></p> <style type= "Text/css" > Miao{position:relative;o Verflow:hidden;} . Miao span{position:absolute;left:50%;top:50%; Miao span img{position:relative;left:-50%;top:-50%;} </style > <p><! [endif]--><br/> </pead><br/> <body></p> <p> Fixed high-width container, picture vertical board. The </p> <p> green container is span to align its upper-left corner with the container's center point. Red is a specific picture, set the negative again so that their center point and the center of the parent container overlap, and eventually reached the vertical bureauThe purpose. </p> <div class= "Miao" > <span></span> </div> <pr/> <div class= "Miao" > <s pan></span> </div> <pr/> <div class= "Miao" > <span></span> </div> &LT;P&G t;</body><br/> </ptml></td> </tr> </table>
Tip: You can modify some of the code before running
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.