去浮动问题:为什么下面的代码clearfix不能去浮动

去浮动问题被搞了好久网上查了感觉好乱,为什么下面的代码clearfix不能去浮动,有没有大佬解释一下

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>lianxi</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        html,body{
            height: 100%;
        }
        .clearfix :after {
            content: '';
            display: table;
            clear: both

        }
/*        .clearfix:after { 
            content:"\200B"; 
            display:block; 
            height:0; 
            clear:both; 
        } 
        .clearfix{*zoom:1;}/*IE/7/6*/*/
        .div1{
            width: 50px;
            height: 50px;
            background: red;
            float: left;
        }
        .div2{
            width: 200px;
            height: 50px;
            background: blue;
        }
    </style>
</head>
<body>
    <div class="clearfix">
        <div class="div1">16</div>
        <!-- <p style="clear: both;"></p> -->
        <div class="div2">20</div>
    </div>
    
</body>
<script>

</script>
</html>
阅读 1.9k
1 个回答

你把 /*/*IE/7/6*/*/ 去掉就好了。。。
细心、格式、、、、

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题