DEV Community

Discussion on: A little trick to left align last row's items with Flexbox

Collapse
 
pedrogritter profile image
Pedro Gritter

If you don't know how many div elements you will have (example rendering an array) a simple solution is to set a max-width for you parent div so that you that at most N elements fit in a row.
Next use the elements as the example above but only with the same width defined as your elements, no height.
This way it will still left align your last row with the added effect that in case you have to add an extra empty row it will have no height!

Collapse
 
stel profile image
St3l

Thank you for this updateπŸ‘ŒπŸ˜Š

Collapse
 
laski profile image
Laski

Hi, Pedro Gritter do you have working example for this?