css - 这是哪个 CSS 错误? (页边距底部,ie6 + ie7)

标签 css internet-explorer-6 internet-explorer-7

在 ie6 和 ie7 中,p 中的 margin-bottom 应用于 pdiv 就在它下面。

换句话说,此代码将在 ie6 和 ie7 中将 20px 的 margin-bottom 应用于 pdiv。在任何版本的 FF、Opera、Chrome/Safari 或 ie8 中都没有问题。

<p style="margin-bottom: 20px;">Hello world!</p>
<div style="float: left; display: inline">
    Hello world, part deux.
</div>

当然,从 div 中删除 float 可以解决这个问题。这是哪个 ie/CSS 错误(如果有的话),我应该搜索什么来找出如何修复它?

附:不幸的是,我无法为 div 指定宽度。

最佳答案

float: left 本质上会导致您的 DIV 容器被推到文档流中可能的最左上角位置。在这种情况下,由于之前的 P 标签未 float ,因此忽略边距底部。这将达到预期的效果,尽管代码不是很干净:

<p style="float: left; display: inline; margin-bottom: 20px;">Hello world!</p>
<div style="clear: left; float: left; display: inline">
    Hello world, part deux.
</div>

但是,理想的情况是简单地从元素中删除 float 并保留它们的原样( block 级元素):

<p style="margin-bottom: 20px;">Hello world!</p>
<div>Hello world, part deux.</div>

也许我缺少这两个容器在您的案例中的预期效果。

关于css - 这是哪个 CSS 错误? (页边距底部,ie6 + ie7),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1594323/

相关文章:

php - 如何在 wordpress 中创建动态商业列表

css - 重力形式的响应按钮

javascript - 是什么让 IE6 不接受输入框中的文本?

css - IE7 Z-Index 问题

css - IE7 菜单背后的图像 z-index

javascript - JQuery 显示/隐藏不工作 IE7

css - 有没有办法做一个 "not adjacent to"选择器,与 + 运算符相反

android - 哪个是移动应用程序开发的最佳跨平台框架?

css - IE6中正文内容div对齐问题

在 IE6 和 IE7 中滚动 div 时,jQuery UI 按钮不会移动(有时会消失)