0

I have a layout with boxes. The count of boxes is dynamic depending on what JSON I retrieve from the server. These boxes need to stack in rows and all the contents inside of the boxes must be fully shown, however the the rows with maximum amount of boxes shoulnd't leave any gaps.

I've achieved this by using flex-wrap: wrap on the parent and flex: 1 on the boxes.

However, if the last row doesn't have as many boxes as the rest of them, they shouldn't strecht all the way to the width of the parent.

enter image description here

As mentioned - the rows with maximum amount of boxes shouldn't leave any gaps and should take up the whole remaining space

enter image description here

Is this even possible? And if it is - how can it be done?

Here is a fiddle showing the problem: https://jsfiddle.net/ymcwnbo2/1/

GeForce RTX 4090
  • 3,091
  • 11
  • 32
  • 58

1 Answers1

0

Add the following to the container

justify-content: flex-start

and remove flex:1 from the boxes

check this https://jsfiddle.net/ymcwnbo2/

Abhidev
  • 7,063
  • 6
  • 21
  • 26