IE8 below margin:0 Auto; solution not centered, IE8 compatibility code

Source: Internet
Author: User

Today wrote a Div, with margin:0 Auto, to define his attributes, let him center, the result is invalid.
At first I thought it was CSS code conflict, check several times, no problem, and then use Firefox and Google Browser test, center ...
Seems to be a browser compatibility problem, suddenly remembered now with the Win7,ie has been upgraded to the IE8, it seems that the problem is IE8 compatibility. Baidu's ....


The workaround is copied to the following:
Ie6,7,firefox under the general use: Margin:auto to achieve, but under the IE8, it is not enough. Two solutions are now available:


Method One (recommended):


First, the document type must be set at the top of the page:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transition al.dtd ">


and add in head:
<meta http-equiv= "x-ua-compatible" content= "Ie=emulateie7"/> Can!


Method Two:


Body setting {text-align:center;width:100%;}
Include all div in <div id= "wrap" >, wrap is set as follows:
#wrap {text-align:left; width:***; margin:0 Auto;}


and add in head:
<meta http-equiv= "x-ua-compatible" content= "Ie=emulateie7"/>


Can!


Method Three:


Replace the wrap layer in two with <center></center>.

IE8 below margin:0 Auto; solution not centered, IE8 compatibility code

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.