| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 | <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <title>Document</title>    <style>        .main {            border: 2px solid #000;            /* overflow: auto; */        }        .one {            background: #f00;            float: left;            width: 200px;            height: 200px;            font-size: 30px;            color: #fff;        }        .two {            background: #0f0;            float: left;            width: 200px;            height: 200px;            font-size: 30px;            color: #fff;        }        .three {            background: #00f;            float: left;            width: 200px;            height: 200px;            font-size: 30px;            color: #fff;        }        /* .empty {            clear: both;        } */        .clearfix::after {            content: "";            display: block;            clear: both;        }    </style></head><body>    <!--         1.溢出隐藏法:在高度塌陷的父级元素上 添加一个属性 overflow:hidden/auto;        2.额外标签法: 在子集添加一个空标签 并添加属性clear:both/left/right; clear:none;        3.伪元素清浮动:        .clearfix::after {            content: "";            display: block;            clear: both;        }        把样式名clearfix添加到对应高度塌陷的父元素上     -->    <div class="main clearfix">        <div class="one">1</div>        <div class="two">2</div>        <div class="three">3</div>        <!-- <div class="empty"></div> -->        我是一段话     </div></body></html>
 |