Css div is always centered on the screen, while css div is centered on the screen

Source: Internet
Author: User

Css div is always centered on the screen, while css div is centered on the screen

Regardless of how the screen slides, The div is always in the center of the screen (IE7 (including IE7) and later versions are supported)

<Div class = "loginBox"> </div>
. LoginBox {background: # FA2; width: 700px; height: 400px; position: fixed; left: 50%; top: 50%; z-index: 11; /* set the negative value of this div's margin-top to half of its own height. The value of margin-left is also the negative value of half of its own width. * // * If the width is 400, margin-top is-200px * // * If the height is 200, margin-left is-100px; */margin:-200px 0 0-350px ;}

 

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.