首页 新闻 会员 周边

position定位

0
[已解决问题] 解决于 2019-07-22 14:49
<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吗?

你猜丶的主页 你猜丶 | 初学一级 | 园豆:183
提问于:2019-07-18 17:31
< >
分享
最佳答案
0

相对对定位不会删除它本身在文档流中占据的那块空间,而绝对定位则会删除掉该元素在文档流中的位置,完全从文档流中抽了出来
<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>
你有地方打错了,仔细看看

奖励园豆:5
微安微安 | 菜鸟二级 |园豆:209 | 2019-07-19 10:39
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册