Force “position: absolute” to be relative to the document and not the parent container

前端 未结 5 1378
遥遥无期
遥遥无期 2020-12-08 12:34

I am trying to insert a div into any part of the body and make its position: absolute relative to the whole document and not a parent element which has a

5条回答
  •  无人及你
    2020-12-08 13:17

    You're looking for position: fixed.

    From MDN:

    Fixed positioning is similar to absolute positioning, with the exception that the element's containing block is the viewport. This is often used to create a floating element that stays in the same position even after scrolling the page.

提交回复
热议问题