views:

5145

answers:

3
+2  A: 

I think gmail just tracks the scroll position on a timer and repositions a div accordingly.

The best solution I've seen is at doctyper.

A simpler jQuery solution that moves an element onscroll: link

rpetrich
How do you get the scroll position, then?
Ben Alpert
I've added the simpler method that tracks onscroll. Feel free to dig through jQuery to find the exact method to use; it might be window.pageYOffset but I'm not certain
rpetrich
The Problem with doctyper is that the phone responsiveness starts to lag when there is too much content to scroll ...
gamma
A: 

I found this just now: http://doctyper.com/archives/200808/fixed-positioning-on-mobile-safari/

(This question was also in the Google search results.)

(Sorry for the necrobump.)

Wevah
+1  A: 

This fixed position div can be achieved in just 2 lines of code which moves the div on scroll to the bottom of the page.

window.onscroll = function() {
  document.getElementById('fixedDiv').style.top =
     (window.pageYOffset + window.innerHeight - 25) + 'px';
};
Abhijit Kalamkar
not OP, but thank you, this is great and simple
Karel Bílek