gpt4 book ai didi

html - 为什么这个div/img在IE8中不居中?

转载 作者:技术小花猫 更新时间:2023-10-29 11:41:35 25 4
gpt4 key购买 nike

我有一个非常简单的主页,我以 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com