How to explain the following css phenomenon

<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8"/>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit"/>
    <style>
      
        .float {
            float: left;
            height: 100px;
            background: rebeccapurple;
        }
        .box {
            clear: both;
            background: green;
            height: 100px;
            margin-top: 10px;
        }
    </style>
</head>
    
    
<body>
   <div class="float"></div>
    <div class="box"></div>
</body>
</html>

increase the value of margin-top when the box element is set to clear:both, or decrease the value of margin-top
the box element does not move
when the box element does not set clear:both, it increases the value of its margin-top, or decreases the value of margin-top
the box element and the float element move together

Mar.01,2021

is mainly caused by outer margin folding. You can learn about outer margin folding first.

Menu