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 position: relative.
position: absolute
position: relative
You're looking for position: fixed.
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.
Notice it doesn't work when...
(...) one of its ancestors has a transform, perspective, or filter property set to something other than none.
transform
perspective
filter
none
1.4m articles
1.4m replys
5 comments
57.0k users