<div style="width:700px;overflow:hidden;" class="parent"><div style="background:yellow;margin-left:-20px;overflow:hidden;" class="son"> <div style="float:left;width:100px;height:300px;border:1px solid red;"></div> <div style="float:left;width:100px;height:300px;border:1px solid pink;"></div> <div style="float:left;width:100px;height:300px;border:1px solid black;"></div></div>以上代碼中.parent是父元素,設置了width:700px;子元素.son繼承過來的時候,應該是700px,但是子元素.son設置了margin-top:-20px;之后,.son的width就變成了720px,當子元素.son設置了margin-top:20px;則.son的width就變成了680px?是什么原理
子元素的margin為負值,就改變繼承過來的width值,是什么原理?
梵蒂岡之花
2018-11-01 14:19:59