<!DOCTYPE html><html><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)
如何解釋以下的css現(xiàn)象
炎炎設(shè)計(jì)
2019-03-14 14:15:28