css - parent's position is absolute and child's position is relative and vice versa

前端 未结 2 958
夕颜
夕颜 2020-12-08 12:29

I have div which hosts another div. Ok, I get the case when the parent is position:relative and the child is position:absolute. I don\'t get what h

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 12:54

    • If the mommy is relative and the child is absolute : the mommy listens to her child. as if to protect him. sort of..

    • If they are both absolute : they have nothing to do with each other. they are strangers to each other.

    • If the parent is absolute and child relative : they are bound. the child moves ( width and height ) towards or away from his mommy.

    It will always be a little strange, there are a lot of great texts about this, but also for me it is always just switching absolute and relative until it works. hope this clears it up a little.

提交回复
热议问题