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 f
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
overflow: auto;
-webkit-overflow-scrolling: touch;
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 !
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...
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:
::-webkit-scrollbar-track {
background-color: #F5F5F5;
}
::-webkit-scrollbar {
width: 12px;
background-color: rgba(0,0,0,0);
}
::-webkit-scrollbar:hover {
background-color: rgba(0, 0, 0, 0.09);
}
::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.3);
border: 2px solid #F5F5F5;
-webkit-border-radius: 100px;
}
::-webkit-scrollbar-thumb:active {
background: rgba(0,0,0,0.61);
-webkit-border-radius: 100px;
}
You can also add vertical arrows with the code below. Similarly horizontal arrows can be included by swapping vertical for horizontal.
::-webkit-scrollbar-button {
width: 12px;
height: 12px;
background-color: #F5F5F5;
background-size: 100%;
}
::-webkit-scrollbar-button:vertical:increment {
background-image: url('../images/arrows/arrow-down.png');
}
::-webkit-scrollbar-button:vertical:decrement {
background-image: url('../images/arrows/arrow-up.png');
}
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/