<div id="div1" style="position: absolute;">
<div id="div5" style="positon:absolute"> <div id="div2" style="position: relative;"> <div id="div3" style="position: absolute;"></div> <div id="div4" style="position: absolute;"></div> </div> </div>
请问下我的div3和div4会定位到div1去了,不应该定位到2吗?
相对对定位不会删除它本身在文档流中占据的那块空间,而绝对定位则会删除掉该元素在文档流中的位置,完全从文档流中抽了出来
<div id="div1" style="position: absolute; width: 1000px;
height: 500px; background: red;">div1
<div id="div5" style="position:absolute; width: 500px; height: 400px; background: yellow;">div5</div>
<div id="div2" style="position: relative; width: 500px; height: 200px; background: green;">div2
<div id="div3" style="position: absolute; margin-right: 50px; width: 400px; height: 100px; background: pink;">div3</div>
<div id="div4" style="position: absolute; margin-right: 100px; width: 200px; height: 200px; background: blue;">div4</div>
</div>
</div>
你有地方打错了,仔细看看