This is the HTML I have :
<div class="image">Image</div>
<div class="legend">
Legend<br/>
width variable height<br/>
the middle of the legend need to be exactly on the bottom of the image, regardless of the height of the legend and image
</div>
<div class="following">The following text should follow immediatly the legend,regardless of the height of the legend or the image</div>
This is the result I want :
This is what I tried :
.image {
height:100px;
background-color:red;
}
.legend {
transform:translateY(-50%);
background-color:blue;
width:300px;
margin:0 auto
}
.following {
background-color:yellow;
margin-top:-45px;
}
Problem is : I don't wan't to have this margin between legend and following text.
The whole attempt codepen is here
Question : any solution to get the desired result without JS ?
(for the record : this is a solution with JS)