To answer your various questions (including in another comment), I think that you are using the wrong positioning method.
Try position:fixed . It is basically the same as position:absolute , except for it relative to the absolute viewport. That is: if the user scrolls, the item remains in the same place on the screen.
So, bearing in mind, you can lay out the overlay position:fixed . In this case, you can have position:absolute (or fixed again, if you want - it should not matter) a modal field.
source share