I’m currently experimenting with horizontal scroll.
I want to make a menu, which a user can scroll vertically like the one from apple. The horizontal scroll is only applied if the menu does not fit on one screen.
1. Create regular div wrapper
Add class horizontal-scroll-menu. We use this class selector under custom code (Part B).
2. Put inside div/link-block “box” note: In this case, i set fixed width (But if you put text/images inside the box you could use “auto”) + Set display to inline-block
important - on desktop no way to scroll by Grab (Without custom JS - example dragscroll.js). Add custom code -or- resize elements on desktop (To avoid scroll ==> like apple example).
Should cause a scrolling mechanism to be provided for overflowing boxes
2/3. CSS white-space Property
The white-space property specifies how white-space inside an element is handled. Read more
nowrap Sequences of whitespace will collapse into a single whitespace. Text will never wrap to the next line. The text continues on the same line until a tag is encountered.
3/3. Inline-block
One common use for display: inline-block is to display list items horizontally instead of vertically. Read more
Thanks for posting this! I’m trying it right now but am pretty new to code/learning along the way… is there any way you know of to utilize this scroll function on mobile, but keep the box widths constant while incorporating text/images. Essentially, I want all of my boxes to be the same width as the user scrolls through them, but my text is of different lengths, so setting “auto” for the width wouldn’t work.
I think it has to do with the custom code and “overflow” but right now, even though I’ve set a max width for my text, it’s not respecting that… (screenshot attached, though I haven’t filled all the different text… trying to make a timeline eventually!).
Any help would be very much appreciated!
Thank you!
Erin
Thanks for posting this. I was looking for something like this to use in my Collection Pages heavy project where collection 1 category are links you can horizontally scroll through, and then clicking brings to collection page with product types.
Brilliant. Exactly what I was looking for. But i tried to replicate it to a collection list and it did not work. If you have the step missing for collection, that would be amazing. Thanks
I’ve implemented this dragscroll to my site and it works perfectly on desktop, but when tested on mobile the whole “bar” jumps around (random left and right) when trying to select different div’s inside. I use it for filtering with 50 ish categories. Hope someone can help and that i explained in a way you can understand the issue.