Div + CSS sets the page center of the DIV module, which is compatible with IE6 +, ff3.0 +, and chrome

Source: Internet
Author: User

To obtain the following page effects, for example, the position control for the mask layer:

PageCode:

 
<DivClass= "Divouter"> <DivClass= "Divinner">Divinner is the center block on the page.</Div> </Div>
 
 
 
After several attempts, we finally adopted the following solution (not compatible with ie5.5 ):
 . Divouter { Position :Relative ; Margin : 0 auto ; /* Ie5.5 not supported */  Margin-top : 25% ; /* If it is set to 25%, the distance from the top margin is half of the page height, which is not understandable. This is true for chrom, ff, and IE6 */  Width : 300px ; Height : 200px ;} . Divinner { Position :Absolute ; Top : -50% ; Width : 300px ; Height : 200px ; Background : # Dedede ;}

 
 

 

 

 

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.