The absolute positioning method of Div center is compatible with IE series browsers and Firefox browsers.

Source: Internet
Author: User

For more information, see the style:
# Dingwei {padding: 10px; Background-color: #003300; color: # ffffff;
Width: 600px; Height: 300px;
Display: block;
Position: absolute;
Top: 50%;
Left: 50%;
Margin-left:-300px;
Margin-top:-150px ;}

Padding: 10px; Background-color: #003300; color: # ffffff;

Width: 600px; Height: 300px; the total width and height of the DIV are set according to your actual situation;

Display: block; display the DIV as a block-level element;

Position: absolute; top: 50%; left: 50%; margin-left:-300px; margin-top:-150px, I think all smart friends can see it.
It is definitely positioning the DIV layer. Of course, you should make it relative to the body tag. Margin-left:-Px; this value is half the DIV width, and margin-top:-150px; is half the DIV height.

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.