I understand how to do a simple horizontal scroll with elements that are all on the single line.
Single line demo: http://jsfiddle.net/YbrX3/1504/
Although how am I able to do a multiline element scroll with CSS, like so:
1 | 3 | 5 | 7 | 9
---------------------------
2 | 4 | 6 | 8 | 10
Here is a solution using a flexbox
- added this style to scrolls
:
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 160px;
I doubled the height of scrolls
and gave it a column
flex-direction. Wrapping it gets you the layout you need.
See snippet below:
.wrapper {
background: #EFEFEF;
box-shadow: 1px 1px 10px #999;
margin: auto;
text-align: center;
position: relative;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
margin-bottom: 20px !important;
width: 100%;
padding-top: 5px;
}
.scrolls {
overflow-x: scroll;
overflow-y: hidden;
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 160px;
white-space: nowrap
}
.scrolls div {
padding: 20px;
box-shadow: 1px 1px 10px #999;
margin: 2px;
display: inline-block;
vertical-align: top;
}
<div class="wrapper">
<div class="scrolls">
<div>
1
</div>
<div>
2
</div>
<div>
3
</div>
<div>
4
</div>
<div>
5
</div>
<div>
6
</div>
<div>
7
</div>
<div>
8
</div>
<div>
9
</div>
<div>
10
</div>
<div>
11
</div>
<div>
12
</div>
<div>
13
</div>
<div>
14
</div>
</div>
</div>
Let me know your feedback on this. Thanks!
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