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元素的最后一個(gè)子元素的marginBottom值不斷減少,并把div的元素的高度輸出到div的第一個(gè)子元素中其中當(dāng)div元素設(shè)置了邊框的時(shí)候,減少最后一個(gè)元素的marginBottom值會(huì)發(fā)現(xiàn)div這個(gè)父元素的高度在不斷減少當(dāng)div元素不設(shè)置邊框的時(shí)候,減少最后一個(gè)元素的marginBottom值會(huì)發(fā)現(xiàn)div這個(gè)父元素的高度不再變化而且下面定義的h1的hello在以上的兩種情況下都可以穿透div里面的文本請(qǐng)問一下如何解釋這種現(xiàn)象
如何解釋下面這個(gè)css現(xiàn)象
明月笑刀無(wú)情
2019-05-23 11:00:01