Why is a div with “position: absolute” not by default relative to the document?

前端 未结 3 628
无人共我
无人共我 2020-12-20 07:38

I thought a general rule is that, whenever a div foo has position: relative, then if none of the parent and ancestor has any non-static posit

3条回答
  •  -上瘾入骨i
    2020-12-20 08:03

    It is work div3 is calculating from body not from div2. Because you not specific "top" position of div than div3 get "top" from div2 and make your top point same as top point of div2. When you add atributte "top: 0px;" to dov3 then you see where is div3 and from which element affected div3 position.

提交回复
热议问题