ie7 float元素 margin-bottom失效

ie7-浏览器,父元素float,子元素如果也float,则magin-bottom失效。
为什么呢?父元素float不是触发BFC了吗?
http://output.jsbin.com/liwajir

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .inner{
            float: left;
            width: 100px;
            height: 50px;
            background-color: #8BB5C0;
            margin: 20px;
        }
        .outer{
            float: left;
            background-color: #F9CC9D;
        }
    </style>
</head>
<body>
    <div class="outer">
        <div class="inner"></div>
    </div>
</body>
</html>
阅读 3.8k
1 个回答

可能是没有清除浮动的原因吧,模拟不出ie7了,只能这么推测一下。试试看

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .inner{
            float: left;
            width: 100px;
            height: 50px;
            background-color: #8BB5C0;
            margin: 20px;
        }
        .outer{
            float: left;
            background-color: #F9CC9D;
        }
    </style>
</head>
<body>
    <div class="outer">
        <div class="inner"></div>
        <div style="clear: both;"></div>
    </div>
    <div style="clear: both;"></div>
</body>
</html>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题