Please see the following example.
ul {
display: flex;
}
li {
flex: 1;
display: flex;
flex-direction: column;
border: 1px solid green;
justify-content: flex-start;
align-items: center
}
ul, h3, h4, p {
margin: 0;
padding: 0;
width: 100%;
}
h3 {
margin-bottom: auto;
}
h4 {
border-top: 1px solid green;
margin-bottom: auto;
}
p {
border-top: 1px solid green;
}
<ul>
<li>
<h3>h3<br>h3<br>h3</h3>
<h4>h4</h4>
<p>p</p>
</li>
<li>
<h3>h3</h3>
<h4>h4</h4>
<p>p</p>
</li>
<li>
<h3>h3</h3>
<h4>h4</h4>
<p>p<br>p</p>
</li>
</ul>
I am using ul
li
html layout and apply flex-box style like that. The problem is that I have to fix this flex box, in which the top of each item aligns equally with each other. I tried to use margin-bottom: auto
, but since the height varies, the layout is 'distorted'.
Could anyone please tell me what to do in this situation? Any other perspective / approach would be appreciated. My description is not good, so if there is anything unclear, just feel free to discuss with me. I really need your help.
Thanks in advance!
Update
This image is my expected result: