I´m searching for ages now but I can´t find a solution ... so hopefully you guys can give me a hint? :-)
I have an unknown number of elements (div´s or li´s) with unknown amount of content. These elements I want to center, also if I have more than one row of elements. If the height of the elements are different (because of different content amount) the elements need to align vertically on the top of each row.
I created an image to make it more clear what I need and what I was able to achieve up to know Please click here
So my first approach was:
Make the div´s to display as "inline-block".
But this way I don´t have them aligned to the top.
Second try was:
Set the divs to float and then center them somehow.
Therefore I found lot´s of ideas here already.
But all of them seem to work only as long as I have one row of elements. With having two or more rows, the centering is gone.
What I found and tried:
– Centering multiline floated elements
– How to center multiple divs inside a container in CSS
– How do I center float elements?
– http://upshots.org/css/css-horizontally-center-a-row-of-floated-elements (which was probably closest to what I need but works only with a known number of elements in one row)
– and more in similar directions ...
Any ideas? :-)
Thanks so much in advance!
Cheers,
Manuel