DIV+CSS implementation of unknown wide-height elements vertically horizontally centered

Source: Internet
Author: User

The DIV+CSS implements the unknown wide-height element vertically horizontally centered. Many students in the interview will encounter such a problem: How to use Div+css method to achieve an unknown width of the high pop-up box vertical horizontal center?? If you use JS, it is good to do, but the use of JS will affect the performance of the page, and can use CSS to achieve what to do with JS it, hey

<! DOCTYPE Html>"en"> <meta charset="UTF-8"> <title>div+css to achieve unknown width and height elements vertical Horizontal Center </title> <style> *{margin:0; padding:0;            }. box {width:1120px;            height:968px; Text-Align:center;        Background: #eaeaea; }. Box span {display:inline-Block; Height: -%; Vertical-Align:middle;            }. Box div {background: #ccc; /*Vertical-align:middle, the picture of the words with this attribute, div words with the Display:block attribute*/Display:inline; }    </style>class="Box"> <!--"0.jpg"alt=""/>--> <div>ASDEWQ</div> <span></span></div></body>

DIV+CSS implementation of unknown wide-height elements vertically horizontally centered

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.