Android browser bug? div overflow scrolling
Asked Answered
M

5

30

Can you make the overflow content of a div scrollable in the Android browser?

It is scrollable in all other modern browsers.

In iOS it is scrollable - however it does not show scrollbars - but it is scrollable via dragging.

A simple example: http://jsfiddle.net/KPuW5/1/embedded/result/

Will this be fixed soon?

Manhood answered 4/11, 2011 at 17:10 Comment(2)
It is a bug: code.google.com/p/android/issues/detail?id=6864 There are several work-arounds: cubiq.org/iscroll-4 Rather than these hacks - the bug should be fixed, with all the hype around HTML I am surprised how poorly it is implemented.Manhood
this seems to be fixed now. some SDKs don't have the latest webviews and can still have this issue thoughGonium
C
25

Android 3.0 and higher have support for overflow:scroll, on < 3.0 it's another story. You might have some success with polyfills like iScroll, however that does come at a cost. It's difficult to implement on sites with complex layouts, and you need to a call a method everytime the content on your site changes. Memory use is also an issue: on already underpowered devices performance may lag because of these kinds of polyfills.

I would recommend a different approach: use Modernizr to detect support for overflow scrolling , add a class to your html tag and use that to rewrite your CSS so that pages scroll 'normally' instead of in a box.

/* For browsers that support overflow scrolling */
#div {
    height: 400px;
    overflow: auto;
}

/* And for browsers that don't */
html.no-overflowscrolling #div {
    height: auto;
}
Cris answered 14/11, 2012 at 13:7 Comment(1)
I think your recommended approach is based on a misconception. Modernizr's overflowscrolling test is not for whether overflow:scroll works in the browser, but whether the browser has support for the *-overflow-scrolling css property, which is different.Allanson
F
8

overflow: scroll; is supported as of Android 3 (API 11).

For a cross-platform (namely iOS <=4.3.2) Cubiq iScroll is an easy-to-implement fix.

Fillender answered 16/8, 2012 at 5:52 Comment(0)
U
3

You could try touchscoll.js for scrollable div elements

Urchin answered 20/5, 2012 at 18:26 Comment(0)
R
0

Just for completeness:

The scrollbars are actually there in Android 2.3, but they are very buggy and by default they are styled to have 0 width, so they are invisible.

You can make them visible by adding styling like:

::-webkit-scrollbar {
    width: 30px;
}
::-webkit-scrollbar-track {
    background-color: $lightestgrey;
}
::-webkit-scrollbar-thumb {
    background-color: $lightgrey;
}

However, the thumb element is not draggable, you can only move it by tapping the track underneath or above it.

Also, these styles will change the look of your scrollbars in all webkit browsers, so best you should add a class that only applies to Android 2.3.

Rudiment answered 31/7, 2014 at 14:3 Comment(0)
H
-5

You can make a DIV scrollable in Android by defining the styles of the scrollbar in your CSS. This article show you how to do it: http://css-tricks.com/custom-scrollbars-in-webkit/

Hygrometric answered 30/8, 2012 at 21:14 Comment(4)
Could you include a short sample here, to prevent this answer from becoming useless if/when that link goes dead?Boschvark
This does indeed show scrollbars on Android 2.3, but doesn't make the div scrollable :(Cris
Husky, I try it on an Android 2.3 and it works. Maybe behavior varies in different devices. Try with this webapp: applications.frenys.com/webapp/?ref=dl&app=116815031665454 (you must touch/click on the empty part of the scrollbar track)Hygrometric
@Hygrometric How does this answer the question?Jaffa

© 2022 - 2024 — McMap. All rights reserved.