6.10 阻止浮动元素覆盖非浮动元素

77 阅读1分钟
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .cube1{
            width: 100px;
            height: 100px;
            background-color: red;
            float: left;
        }
        .cube2{
            width: 200px;
            height: 200px;
            background-color: blue;
            /* 开启bfc属性 */
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div class="cube1"></div>
    <div class="cube2"></div>
</body>
</html>