I'd like to see if someone knows a trick to achieve this problem, using only CSS:
Say I have a two, three or four column layout (the number is dynamic), each one of these columns will have 5 different sections inside, and each one of these sections will have a variable amount of content.
Is it possible to vertically align each one of the sections with the sibling columns' sections even if their content is not the same height, using only CSS (instead of a JS equalizer solution)?
I know this would be quite easy with a table, but I have to completely switch the layout to rows if there are more than four items.
I was trying to use Flexbox but haven't achieved the desired result, and I'm not sure I can use Grid with a variable amount of columns.
I was trying to do it using Flexbox as shown in the Codepen https://codepen.io/ramonlapenta/full/gowLqw/
With the reasoning of being able to make each section grow equally (stretch) in the available space, since the .item-compare
div is already stretched to the same height as its siblings, but this is not working because the growing/shrinking properties refer to the available space, not to the content of the items.