我正在嘗試將一個DIV與"margin:auto"
對齊。它正常工作與Chrome和FF,但下面的代碼不與IE居中DIV:使用IE定位DIV
CSS
#container {
margin:auto;
width:950px;
height:50px;
background:#000;
}
HTML
<div id="container"></div>
我在做什麼錯?
感謝,
喬爾
編輯(完整的HTML/CSS代碼):
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.2.0/build/cssreset/reset-min.css">
<style>
#container {
margin: 0 auto;
width:950px;
height:50px;
background:#000;
}
</style>
</head>
<body>
<div id="container"></div>
</body>
</html>
?我通常定義一個'寬度',然後設置'margin:0 auto'並且它在IE中工作正常... – 2010-10-21 13:44:59
試過用IE9測試它!我使用上面的代碼... – Joel 2010-10-21 13:45:53
是的,但正如Sime所說的使用margin:0 auto;您只有保證金:汽車 – Rob 2010-10-21 13:48:34