如何解决Firefox和IE7中的这种不一致



当我在Firefox4中清除一个元素时,它会转到下一行,中间留有一些间距。在IE7中,它会转至下一行而不留任何空间。。

 <!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
#a{border:#000 thin groove;float:left;}
#b{border:#000 thin groove;float:left;clear:left;}
</style>
</head>
<body>
<p id="a">Testing</p>
<p id="b">Testingb</p>
</body>
</html>

对于p元素,大多数浏览器的默认margin-topmargin-bottom都大于零。Internet Explorer没有。

p { margin: 0; }添加到您的样式中会修复它。

最新更新