Unify and align elements that are inside a number of divs that are in a flex container [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-24 19:33:50

问题


I have some cards that lie inside a flex container, those cards include some elements. It currently looks like this:

Sometimes the headline in a card takes two lines and the other headlines don't, which causes an empty space at the other cards:

What I want is to align each element with its corresponding one in all cards, so the first headline should always be above the first "drawn" line, the second head line in between the drawn lines and the meta data below the second drawn line.

The card has structure:

<a class="card" href=#>
    <img src=# />
    <h5>First Headline</h5>
    <h4>Second Headline</h4>
    <div class="post-meta">
    ...
    </div>
</a>

Card has css:

margin: 15px 10px;
flex-grow: 1;
text-align: center;
flex-basis: 250px;
display: inline-block;

Card container has css:

padding:4%;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: space-around;
align-items: stretch;

I tried couple of things. I tried relative positioning the post meta to the bottom of the card using bottom: 0; but it overlapped with the above element. Tried using another flex container as described in this Answer but I can't seem to figure out how to apply it in nested divs.

The top solution I am looking for is to set the height of the headlines to the maximum height. Any help would be appreciated.

来源:https://stackoverflow.com/questions/48568568/unify-and-align-elements-that-are-inside-a-number-of-divs-that-are-in-a-flex-con

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!