prevent div from scrolling despite position: absolute

Like i said in my comment:
You should use position: fixed.
It is similar to absolute, but it don't scroll with the whole site, it is "fixed" on the given position.


What you want to do is:

position: fixed;

Because position: absolute; sets position relative to parent coordinates and when the document is scrolled, absolute position is STILL relative to parent's and parents (through whatever count of levels) is relative to whole document position.

On the other hand position: fixed sets position relative to window's and not document's. That way your element stays in the same place when scrolled.

Tags:

Css