yupp, I'm one of these guys who want to develop mobile apps with HTML5. On Android and iOS. Sounds crazy I know. Sadly I have a problem...
I have a classic app with a footer and header and a content which should be scrollable. On iOS this works fantastic! The header and footer have "position: fixed" to top/bottom and the content uses native scrolling momentum with "-webkit-overflow-scrolling: touch;". I know that "-webkit-overflow-scrolling: touch;" isn't available on Android, but this property is not only ignored, scrolling doesn't work at all!
So please can anyone tell me how to get "native" scrolling on iOS and "good" scrolling on Android with the same markup and style? E.g. if I can use native scrolling with momentum - great, if not - plain scrolling.
Note: I only need to support recent versions for now (no Android 2.3!), so I don't want JS-Fallbacks like iScroll 4.
.content {
// no(!) scrolling on Android - why?
overflow-x: hidden;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
JSFiddle: http://jsfiddle.net/bmJxN/
Thanks!
Adding an additional note here due to behaviour that doesn't seem to be explained properly elsewhere.
When using 'overflow: auto' or 'overflow: scroll' Chrome for Android will display scrollbar indicators only momentarily on page load before hidding them (unlike the typical behaviour of desktop browsers). To compound matters these indicators are so thin and translucent they are easily missed.
This may not be an issue for general page scrolling; however, the loss of scrollbars to indicate additional content presents a serious UX problem when used to scroll areas of the page (such as for full-page apps).
To rectify this you can add custom scrollbars. When using 'overflow:auto' these scrollbars will only be shown when the content exceeds the visible area (just like on desktop browsers).
Add the following code to your CSS:
You can also add vertical arrows with the code below. Similarly horizontal arrows can be included by swapping vertical for horizontal.
Note the last two lines require arrow images to be present, but was unable to add these to the post (probably due to their small size).
Other scrollbar properties can also be customised. The guide below provides a detailed explanation:
http://poselab.com/en/custom-scrollbars-in-webkit/
It will now work, there are lot of reasons for that. What you can do is use any third party library to achieve this task. I used one of the open source libraries from github to get the result :- The library is here
Hope it will be useful...
Sorry for digging up an old post but as there seem to be no satisfying answer I thought I would add my 2cents for anybody ending up here like me.
Talking about the general problem of scrolling in mobile WebApps, scrolling & momentum on mobile browsers are a pain as there is a wide variety of different implementations depending on the platform : Android browser != Chrome != Safari != opera etc, and Android < 3 does not support scrolling as well as newer versions, just like iOS < 5.
The situation is complicated, and may mot be a problem for iOS where most devices are on iOS 5 or 6, but it is a real problem with Android fragmentation.
To get a better grasp at this, you could read this.
To respond to this, as you have already pointed out, there are fallbacks such as iScroll or more recently, Overthrow that you may handle better the native implems and JS fallbacks. More recently, the Financial Times team published the FTScroller library that looks also promising.
Now for your situation, if you only want to support Android 4+ & iOS5+, you should be able to make it work both with momentum using only fixed positioning and
on your scrollable content (you don't need to specify "overflow-x:hidden" if using auto property). If not, you may have made a mistake in your fixed positing or some other css layout property ? (inherited body props etc).
UPDATE : I should have done this before posting my answer, but I just tested the fiddle on my Nexus4 and your code does work in Chrome : which probably mean that you tested on an older device without Android 4+ or with a browser that did no support the overflow property ?
Side notes :
All this to say that something as simple as scrolling is far from perfect in mobile WebApps, and it's even worse in WebViews performance-wise (when developing PhoneGap apps for example). Good luck !