How to Enable Responsive Horizontal Scrolling for Flex Items in CSS?
I'm trying to create a responsive horizontal scrolling effect for a set of .package items using Flexbox in CSS. When there are more items than can fit on the screen, I want the overflow items to be accessible via horizontal scroll. This should be responsive based on the user's screen width.
However, I'm encountering issues when the screen width is smaller than 1200px. The items either overflow without enabling scroll, or they don't display as intended.
html code
css code
6 Replies
limit the width of
.package-container
with max-width
Thank you so much, you've helped me a lot with this!
you're welcome
Why so many nested divs though? Can't you combine parent-container, package-container, package-wrapper all in 1 div instead of 3 nested ones?
not really, no
it's possible to reduce by 1 div, so there's 2 divs
but you need 2
you can try to go lower, but i've seen flex doing funky things
the problem is that you need a parent that is overflowing, and one that isn't overflowing, to restrain the scrollbar
I see, yes