【发布时间】:2011-04-01 12:34:58
【问题描述】:
我有一个 html 页面:
<html>
<head>
<title>
All Time Set Window
</title>
</head>
<body>
<div align="center" style="width:1000px; height:100%; margin-left:auto; margin-right:auto;">
<div style="width:100%; height:20%; background-color:#F8E0E0; float:top;">
<div align="center">This is Header</div>
</div>
<div style="width:100%; height:60%; background-color:#F5F6CE;">
<div align="center" style="width:70%; background-color:#E3F6CE; float:left;">This is Left Frame</div>
<div align="center" style="width:30%; background-color:#E0E0F8; float:right;">This is Right Frame</div>
</div>
<div style="width:100%; height:20%; float:bottom; background-color:#F8E0E0;">
<div align="center">This is Footer</div>
</div>
</div>
</body>
</html>
我已使用 Margin-left 和 Margin-right 来自动将 div 置于中心位置。这适用于 Mozilla 而不是 Explorer。相同的解决方案是什么。
【问题讨论】:
-
边距:自动;不能在 Explorer 中工作,只能在 Mozilla 中工作。这就是问题所在。
-
但是,我再次说问题在于不能使用 IE8+。什么是相同的解决方案。我试过 1)margin-left:auto;边距右:自动; 2) 边距:自动; 3) 边距:0px 自动;还是……
-
如果你不强迫 IE 进入怪异模式,你会变得更好。在 HTML 的开头添加
<!DOCTYPE html>。