Imagine a horizontally scrollable div which contains two vertically scrollable divs.
You are supposed to scroll horizontally to navigate, then scroll vertically in the inner divs to read content.
/* MINIMAL RESET */
body, html {
height: 100%;
margin: 0;
padding: 0;
}
* { box-sizing: border-box; }
<div style="
overflow-x: scroll;
white-space: nowrap;
width: 100%;
height: 100%;
position: relative;
background-color: black;
">
<div style="
width: 100%;
height: 100%;
left: 0%;
top: 0px;
margin: 0px;
position: absolute;
display: inline-block;
background-color: green;
">
<div style="
width: 100%;
height: 100%;
overflow-y: scroll;
">
<div style="
width: 100%;
height: 200%;
">
</div>
</div>
</div>
<div style="
width: 100%;
height: 100%;
left: 100%;
top: 0px;
margin: 0px;
position: absolute;
display: inline-block;
background-color: blue;
">
<div style="
width: 100%;
height: 100%;
overflow-y: scroll;
">
<div style="
width: 100%;
height: 200%;
">
</div>
</div>
</div>
</div>
After looking at this question I figured out that you can set -webkit-overflow-scrolling : 'touch'
, but in my case I need to look for another solution, since I manipulate the horizontal scroller when the scroll has ended, and touch-scroll does in this case break it.
The following example works fine in Chrome, also Chrome on Android, however on iOS, one is not able to scroll horizontally due to the focus of the input, which always gets passed onto the vertical scrollers.
How do I make both the horizontal and the vertical divs scrollable for iOS, so it works the same way as it does in Chrome?
Set the overflow-y: hidden; and overflow-x: auto; that will automatically hide the vertical scroll bar and present only the horizontal scrollbar. The white-space: nowrap; property is used to wrap text in a single line. Here the scroll div will be horizontally scrollable.
Horizontal scrolling can be achieved by clicking and dragging a horizontal scroll bar, swiping sideways on a desktop trackpad or trackpad mouse, pressing left and right arrow keys, or swiping sideways with one's finger on a touchscreen.
The scrolling images were acheived using the HTML <marquee> tag. Using this tag, you can give your images a horizontal scroll (from right to left, left to right) or a vertical scroll (top to bottom, or bottom to top). Note that the <marquee> tag isn't an offical HTML tag (but it is recognized by most modern browsers).
I think you'd be better off taking the carousel approach where you'd be moving a container when swiping, rather than user the "native" scroll behaviour.
That way you'll be able to slide your DIVs left and right with JS, and scroll up and down using regular scrolling.
You need to replace all overflow-*AXIS*
to simple overflow
auto
:
<div style="overflow: auto; white-space: nowrap; width: 100%; height: 100%; position: relative; background-color: black;">
<div style="width: 100%; height: 100%; left: 0%; top: 0px; margin: 0px; position: absolute; display: inline-block; background-color: green;">
<div style="width: 100%; height: 100%; overflow: auto;">
<div style="width: 100%; height: 200%;"></div>
</div>
</div>
<div style="width: 100%; height: 100%; left: 100%; top: 0px; margin: 0px; position: absolute; display: inline-block; background-color: blue;">
<div style="width: 100%; height: 100%; overflow: auto;">
<div style="width: 100%; height: 200%;"></div>
</div>
</div>
</div>
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