Documentdiv{/*border:1pxsolid#000;*/width:50%;margin:0auto;font-size:16px;text-align:center;}#dot{margin-bottom:50px;}h1{margin:0auto;width:20px;}123456789.hellowindow.onload=function(){functionanimate(){document.getElementById('height').innerHTML=window.getComputedStyle(document.body.firstElementChild).height;vardot=document.getElementById('dot');varm=window.getComputedStyle(dot).marginBottom;console.log(m);m=parseInt(m);m-=1;document.getElementById('dot').style['margin-bottom']=m+'px';requestAnimationFrame(animate);}animate();}腳本的內(nèi)容是把div元素的最后一個子元素的marginBottom值不斷減少,并把div的元素的高度輸出到div的第一個子元素中其中當(dāng)div元素設(shè)置了邊框的時候,減少最后一個元素的marginBottom值會發(fā)現(xiàn)div這個父元素的高度在不斷減少當(dāng)div元素不設(shè)置邊框的時候,減少最后一個元素的marginBottom值會發(fā)現(xiàn)div這個父元素的高度不再變化而且下面定義的h1的hello在以上的兩種情況下都可以穿透div里面的文本請問一下如何解釋這種現(xiàn)象
如何解釋下面這個css現(xiàn)象
海綿寶寶撒
2019-05-23 11:11:45