I got the following use case:
You can see three identical boxes: Each box beginns with a big rectangle box, that has a picture and variable content and thus has variable height. the rest consists of a list, that is vertical aligned bottom, so that they should get the same height.
My goal is to "synchronize" the height of the < li >'s in each of these boxes. So it should not be important how many text you enter in such a < li > tag, the design should automatically handle the word-break and align the content like it was a row.
In other words, like Abhitalks stated, I want to align list-items to their peers in other content columns depending on the mutual heights.
Now, I used display flex in order to vertical align the list to bottom of the element. You can find my used solution here: Vertical alignment of floating divs
But now I got the problem, that if the list has no identical content (e.x. more than two rows per listitem, the whole thing shifts to the top.
However, is it somehow possible to simulate a row behavior with flexbox, but actually having a column structure?
I need a column structure, so I can easily get a responsive layout.
hope you understand my problem
thanks in advance!
UPDATE:
Here is the fiddle: http://jsfiddle.net/a1yr4u84/3/
You can see, that I made < br / >'s inside the li's content, in order to make the content fit.
<li>one <br /> two</li>
<li>one <br /> two <br /> three</li>
<li>one<br /><br /></li>
However, I can't control how many text there is going to be in the li's. And I don't want the user to hack with < br / >s but let the design handle the content, so I want the list inside the columns to behave like a row
You need nested
flex
here. Given this markup:First
flex
the wrapper which will layout the columns in a row, and give aflex-basis
of33%
(approx) to the columns to allow for variable content in first columns to space out.:Next,
flex
the columns to layout the image and content list in columns. This timeflex-basis
is not required:In order to keep the lists vertically aligned to the bottom, just provide a
margin-top:auto
to the list content:Here is a complete example..
Fiddle: http://jsfiddle.net/abhitalks/a1yr4u84/1/
Snippet:
Edit:
(based on op's comment)
If you want the list-items to align to their peers in other content columns depending on the mutual heights, then you cannot do this with CSS. I see that you have tagged the question with
jQuery
, so I am proposing a quick-and-dirty solution using jQuery.Calculate the
height
of the list items, and apply that height to all the corresponding items in other columns:Fiddle 2: http://jsfiddle.net/abhitalks/a1yr4u84/4/
Snippet 2:
Note: I have used an arbitrary number of
10
to loop thru the list-items. In production code, you must calculate the number of the list items in the largest list.Set css
line-height
to the row objects. All need to be set of the same height.