Position absolutely positioned DIV relative to (also absolutely positioned) parent DIV?

前端 未结 3 552
梦毁少年i
梦毁少年i 2021-01-23 14:23

This is one problem I always have when i\'m fixing layouts. I\'ve got a absolutely positioned DIV, I place a child-DIV inside which also needs to be absolutely positioned. But I

3条回答
  •  天涯浪人
    2021-01-23 14:34

    An absolutely positioned element is positioned with respect to the edges of its nearest ancestor that is not positioned (i.e. not position: static).

    Since the parent element is position: absolute, the child will be positioned with respect to its edges.

    So you appear to be asking how to get behaviour you already have. The comment in your first example appears to be incorrect.

提交回复
热议问题