其他分享
首页 > 其他分享> > 清除浮动==双伪元素清除浮动

清除浮动==双伪元素清除浮动

作者:互联网

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    代码简洁
    <style>
       .clearfix:before,
       .clearfix:after {
           content: "";
           display: table;
       }
       .clearfix:after {
           clear: both;
       }
        .clearfix {
            *zoom: 1;
        }

        .box {
            width: 800px;
            border: 1px solid blue;
            margin: 0 auto;
        }

        .damao {
            float: left;
            width: 300px;
            height: 200px;
            background-color: purple;
        }

        .ermao {
            float: left;
            width: 200px;
            height: 200px;
            background-color: pink;
        }

        .footer {
            height: 200px;
            background-color: black;
        }
    </style>

</head>
<body>
    <div class="box clearfix">
        <div class="damao">大毛</div>
        <div class="ermao">二毛</div>
        <div class="ermao">二毛</div>
        <div class="ermao">二毛</div>
        <div class="ermao">二毛</div>
        <div></div>
    </div>
    <div class="footer"></div>
</body>
</html>

标签:浮动,width,clearfix,清除,双伪,height,color,二毛,200px
来源: https://blog.csdn.net/jjlome/article/details/121453021