I want to achieve this effect within Bootstrap 4 columns/cards:
Is it possible with flexbox?
This is my source code I play with:
https://jsfiddle.net/dandaka/us04p2vg/
<div class="container">
<div class="row">
<div class="col">
<div class="img-top"><img src="https://placehold.it/350x100" alt="" class="img-fluid"></div>
<div class="text-bottom">Lorem ipsum</div>
</div>
<div class="col">
<div class="img-top"><img src="https://placehold.it/350x50" alt="" class="img-fluid"></div>
<div class="text-bottom">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt</div>
</div>
<div class="col">
<div class="img-top"><img src="https://placehold.it/350x250" alt="" class="img-fluid"></div>
<div class="text-bottom">Lorem ipsum dolor sit amet</div>
</div>
</div>
</div>
I had thought about following solutions:
- Use multiple rows for image and text. Will work bad when stacking in small breakpoints. And whole card should have hover state, which will work bad when broken in 2 rows.
- Use Bootstrap cards. They seem to work only with fixed height images.
- Use baseline alignment in flexbox. Can't find any example, where two elements grow in different directions from one axis.
- Fix text block height in pixels. Not a solution at all, just a workaround.
Can't think about anything else.