开发者

IE bug - content floats left

Why does a page floats lef开发者_如何学Ct in IE6 and IE 7?

buggy site


To work around buggy older versions of IE, you can center it something like this:

body{
  text-align:center; /* for older browsers */
}

#main_container{
  margin:0 auto;
  width:1000px;
  text-align:left; /* this is important */
}


IE6+ supports the "auto" value on margin property. However, it requires to display the page in standards-compliance mode. Removing the redundant <pre> elements before the doctype will solve the entire problem, without need to use text-align.


Your page is invalid HTML, so I’d recommend you to make it valid first / as well. Esp. the errors and <pre> tags before your doctype.

To your actual problem: IE does not interpret margin(-left): auto according to standard. To work around it do a text-align:center in the surrounding block element (<body> in your case) and text-align to your preference on the actual element (.container_12 in your case) again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜