Force “position: absolute” to be relative to the document and not the parent container
问题 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 . 回答1: You will have to place the div outside of the position:relative element and into body . 回答2: 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