<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>清除浮动</title>
    <style>
        #box1{width: 200px; border:1px black solid}
        #box2{width: 100px; height:200px;background-color: red;
            float: right;}
        .clear:after{
            content: '';
            clear: both;
            display: block;}
    </style>
</head>
<body>
    <div id="box1" class="clear">
        <div id="box2">       </div>

    </div>
    塌陷
</body>
</html>