我有一个非常简单的保存页面,我以div, anchor 和图像为中心构建了该页面。由于某种原因,它不会以IE8(两种模式)居中,我希望有人可以告诉我原因。我还没有机会在其他IE浏览器中进行尝试。我已经在Chrome和FF3中尝试过了,可以正常工作。

<html>
<head>
<title>Welcome</title>
<style>
    #pageContainer {width:300px;margin:0 auto;text-align:center;}
    #toLogo{border:none; }
</style>
</head>
<body>
    <div id="pageContainer">
    <a href="http://portal.thesit.com" id="toSite"><img src="LOGO_DNNsmall.png" id="toLogo"></a>
    </div>
</body>
</html>

我说这真的很简单。 :)

谢谢,

布雷特

最佳答案

您是否真的要页面在怪癖模式下工作?一旦我添加了doctype以强制采用标准模式,您的HTML中心就可以正常运行:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>Welcome</title>
<style>
    #pageContainer {width:300px;margin:0 auto;text-align:center;}
    #toLogo{border:none; }
</style>
</head>

<body>

<div id="pageContainer">
    <a href="http://portal.thesit.com" id="toSite">
    <img src="http://stackoverflow.com/content/img/so/logo.png" id="toLogo"></a> </div>

</body>
</html>

关于html - 为什么此div/img不在IE8中居中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/816343/

10-12 12:30
查看更多