在这种情况下,Internet Explorer似乎没有提供适当的保证金额度。它看起来像从盒子顶部测量边距并忽略填充。为什么是这样?有没有很好的解决方法?这里有一个例子:带有填充的div内的Internet Explorer保证金问题
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
.messagebox
{
border: solid 2px black;
background: blue;
color: white;
padding: 10px; /* Problem only when padding set */
}
h1, h2, h3, h4
{
margin-top: 12px;
}
</style>
</head>
<body>
<div class="messagebox" style="width: 300px">
<h4 style="text-align: center">In IE, this text is 10px higher than in FF.</h4>
</div>
</body>
</html>
我在IE7和FF3上工作。谢谢。
此问题的快速解决方案是将您的文档类型更改为严格的HTML 4.01。 – 2009-05-29 18:04:03