I made a small webpage with a scrollable div. When I load it in a browser, it works fine. But when I load it in a webview inside Android, it doesn't let me scroll the div. Is there a workaround for this or do I have to use a different design? I am talking about websites like this.
For vertical scrollable bar use the x and y axis. Set the overflow-x:hidden; and overflow-y:auto; that will automatically hide the horizontal scroll bar and present only vertical scrollbar. Here the scroll div will be vertically scrollable.
In order for overflow to have an effect, the block-level container must have either a set height ( height or max-height ) or white-space set to nowrap . Setting one axis to visible (the default) while setting the other to a different value results in visible behaving as auto .
setScrollContainer(false); Don't forget to add the webview. setOnTouchListener(...) code above to disable all scrolling in the webview.
The overflow-x CSS property sets what shows when content overflows a block-level element's left and right edges. This may be nothing, a scroll bar, or the overflow content.
Unfortunely, scrollable div's just aren't supported on most current mobile Webkit browsers. A great alternative to native support is the iScroll Javascript library, which can simulate real scrolling:
http://cubiq.org/iscroll
Copy/pasted from the project description on that page:
The overflow:scroll for mobile webkit. Project started because webkit for iPhone does not provide a native way to scroll content inside a fixed size (width/height) div. So basically it was impossible to have a fixed header/footer and a scrolling central area. Until now.
Version 3.3 and later support Android >= 1.5.
You can use pseudo elements of webkit to customize the scroll-bar style.
Try this:
::-webkit-scrollbar {
width: 12px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
-webkit-border-radius: 10px;
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
-webkit-border-radius: 10px;
border-radius: 10px;
background: rgba(255,0,0,0.8);
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
background: rgba(255,0,0,0.4);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With