I have a card with two parts.
-
One part with a pic
-
another part with a text
My image take 80% of the card and the other part for text 20%.
I could like to vertical align the text then define padding.
I would like this :
And i currently have this :
I tried few things
`vertical-align: baseline;
/* */
align-item:flex-start;
/* */
display: flex;
justify-content: flex-start;
align-item: center.`
My current code is :
HTML:
<div class="card">
<img
src=".#.jpg"
alt="#"
/>
<div class="card-h3">
<h3>Parc national des Calangues</h3>
</div>
</div>
CSS:
.card img {
width: 100%;
height: 80%;
object-fit: cover;
}
.card-h3{
display: flex;
vertical-align: baseline;
}
3
Answers
This is a great use case for grid because it allows you to control the layout in two directions.
Simply add some padding: