110
rated 0 times
[
115]
[
5]
/ answers: 1 / hits: 30312
/ 13 Years ago, mon, april 11, 2011, 12:00:00
I have to move a div when the the user scrolls, but need to use pure JavaScript.
position: fixed;
will not work with the layout. The div's original position is relative to something else. Is there a simple implementation using an event like onscroll
, to detect how many pixels the page moved up or down, and change the position of the div accordingly?
The div only needs to move vertically. So if I can detect how many pixels the page has moved I can just add or subtract that to the location of the div.
More From » vertical-scrolling