I'm creating flexbox cards to display three elements. A title, an <hr>
and a paragraph. The title text length varies, which creates a varying height.
I'd like to have all the titles have the same height, so that each card is uniform. If this is not possible, I would like the paragraphs to be horizontally aligned on each card.
I've tried giving the title a flex: 1
property to push the paragraph down, but it creates too much space.
Here is codepen and demo:
body {
max-width: 1180px;
margin: 0 auto;
}
h2,
p {
margin: 0;
padding: 0;
}
h2 {
font-size: 18px;
}
/*******************************************************/
.cards {
display: flex;
}
.card {
border: 1px solid;
display: flex;
flex-direction: column;
margin: 0 0 25px 0;
width: 50%;
}
.card-title {
text-transform: uppercase;
text-align: center;
margin: 0 0 25px 0;
}
.card-paragraph {
text-align: center;
}
hr {
height: 3px;
width: 100%;
background: #333;
}
/*******************************************************/
<body>
<div class="cards">
<div class="card">
<div class="card-title">
Title one IS LONGER THAN TITLE TWO
</div>
<hr>
<div class="card-paragraph">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text.
</div>
</div>
<div class="card">
<div class="card-title">
TITLE TWO
</div>
<hr>
<div class="card-paragraph">
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
</div>
</div>
</div>
</body>
What I want:
What is happening: