在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5  HTML/ 如何解釋以下的css現(xiàn)象

如何解釋以下的css現(xiàn)象

<!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>

在box元素設(shè)置 為clear:both 時(shí) 不斷增大其 margin-top的值,或者減少margin-top的值
box元素并不會(huì)移動(dòng)
當(dāng)box元素沒(méi)有設(shè)置clear:both 時(shí) 不斷增大其 margin-top的值,或者減少margin-top的值
box元素 和 float 元素會(huì)一起移動(dòng)

回答
編輯回答
任她鬧

主要還是外邊距折疊搞的鬼,你可以先去了解一下外邊距折疊。

2017年12月1日 21:07