简体   繁体   English

中心div使用边距

[英]center div using margin

im trying to center a div(only horizontal) using the following css 我正在尝试使用以下css将div(仅水平)居中

.body_div 
{

  width: 900px;
  margin-left:  auto;
  margin-right: auto;
  background-color: #f8f3ed;
}

and it does it work in chrome and ff but not in ie 它确实可以在chrome和ff中工作,但不能在即

take a look here 在这里看看

eventually i used the same code in another site too and it worked well in ie too 最终我也在另一个站点中使用了相同的代码,并且在例如

now a hell lot another problem... the borders around the #courses and #call are not shown in ie... thanks 现在又是一个又一个问题...在#courses和#call周围没有显示边界,即...谢谢

Remove the comment before the DOCTYPE. 在DOCTYPE之前删除注释。 That places IE in quirks mode where it doesn't supports all standards. 这使IE处于不支持所有标准的怪癖模式


These are currently the top lines of your site: 目前,这些是您网站的顶行:

<!--
To change this template, choose Tools | Templates
and open the template in the editor.
--> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

Change them to this: 将它们更改为此:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"> 

使用单个边距设置:

margin: 0 auto;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM