r/csshelp • • Jun 26 '23

flex-wrap with flex-basis?

I have 8 items and I'm trying to display them in 2 columns by default, but shrink (wrap?) to 1 column as the window shrinks.

So I'm using flex-basis 50% like so:

.flex-container {

display: flex; flex-wrap: wrap; }

.flex-container > div { flex-basis: 50%; text-align: left; }

That successfully limits the columns to two, however the problem is that it's not wrapping, so no matter how narrow the window gets it remains at 2 columns.

I understand that flex-basis and flex-wrap don't always play well together, as I've just discovered flex and have been googling around, but I don't understand how exactly or why.

How should I go about getting a maximum of 2 columns, yet still be able to wrap to 1?

1 Upvotes

5 comments sorted by

View all comments

Show parent comment

1

u/featuredoffline Jul 02 '23

honestly this is very helpful, im still struggling with css.