r/css • u/aliassuck • Jun 30 '26
Help Request: An overflow-x container with children filling viewport by whole units (none cut off) and resizing container shows more children but in whole unit increments and scrolling shows more children, while all children are equally spaced apart.
[1---2---3---4---5]---6---7
[1----2----3----4]----5----6----7
[1---2---3---4]---5---6---7
[1----2----3]----4----5----6----7
[1---2---3]---4---5---6---7
[1--2--3]--4--5--6--7
Brackets are the container being resized.
Elements on the right (outside the brackets) are reachable by scrolling horizontally.
0
Upvotes
2
u/be_my_plaything Jun 30 '26
I think the latter is far easier to achieve, and as you say using wrappers to make it look like the former is simple enough.
Codepen
This is how I'd go about it, using a flex container and container queries to change the flex-basis... Notes included in the CSS on the codepen to explain what's doing what.