I have some text with two images floating around it:
<!--This is obviously a simplified version, there are other styles needed for the images below-->
<div id="wrapper">
<h2>Title</h2>
<figure id="image1" style="float: left">
<img />
<figcaption>Caption</figcaption>
</figure>
<figure id="image2" style="float: right">
<img />
<figcaption>Caption</figcaption>
</figure>
<p>Lorem Ipsum</p>
</div>
This is how it looks like:
What I would want is either the first or the second image to be positioned the the very bottom of the paragraph. Something like this (made using Photoshop):
I obviously cannot set position: absolute
, since the text would no longer float around the image.
I cannot display the wrapper as a flexbox
, since it alignes the elements on one line (or multiple lines) and breaks everything:
I even tried displaying the wrapper as a table
and aligning the figure to the bottom using display: table-cell; vertical-align: bottom
, but float no longer works in that case and the figure is aligned to the center.
The only partial solution I managed to get was using clear: both
on the figure:
The problem with this is that when resizing the page the height of the paragraph changes, the image is no longer at the bottom of it.
The only similar answer I could find on SO was this one, but it didn't work in my case since I don't know the paragraph height in advance.
Any ideas to make it work? Thanks in advance.