我创造了这个人为的例子来说明我的问题。有两个段落中间有一个div。div的高度和行高都设置为0,所有边距也都为0。我希望这两个段落彼此相邻,与div完全没有任何间隔,但是IE6中的情况并非如此。在所有其他浏览器中,它似乎都工作得很好。
下面是所有样式都内联的HTML:
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Test</title>
</head>
<body>
<div id="container" style="border: 1px solid blue;">
<p style="margin: 0;">
Some text
</p>
<div style="height: 0; line-height: 0; margin: 0; border: 1px solid red;">
</div>
<p style="margin: 0; border: 1px solid green">
Should be right below "Some text"
</p>
</div>
</body>
</html>
我添加了一些边框,这样你就可以更容易地看到发生了什么。
以下是IE6的截图:
有什么办法可以去掉div底部(红色)和段落顶部(绿色)之间的小间隙吗?