There is a wonderful blog entry:
http://www.kylejlarson.com/blog/2011/fixed-elements-and-scrolling-divs-in-ios-5/
Along with the demo here:
http://www.kylejlarson.com/files/iosdemo/
In conclusion, you can use the following in a div containing your main content:
.scrollable { position: absolute; top: 50px; left: 0; right: 0; bottom: 0; overflow: scroll; -webkit-overflow-scrolling: touch; }
The problem that I think you are describing is when you try to scroll up to a div that is already at the top, then it scrolls the page instead of the div and causes a bounce effect at the top of the page. I think your question asks how to get rid of this?
To fix this, the author suggests you use ScrollFix to automatically increase the height of scrollable divs.
It's also worth noting that you can use the following to prevent the user from scrolling, for example. in the navigation element:
document.addEventListener('touchmove', function(event) { if(event.target.parentNode.className.indexOf('noBounce') != -1 || event.target.className.indexOf('noBounce') != -1 ) { event.preventDefault(); } }, false);
Unfortunately, there are still problems with ScrollFix (for example, when using form fields), but the list of problems on ScrollFix is a good place to look for alternatives. Some alternative approaches are discussed in this issue .
Other alternatives also mentioned in the blog post, Scrollability and iScroll
Alasdair McLeay Sep 20 '13 at 15:36 2013-09-20 15:36
source share