JSFiddle - React, Tailwind, and code Playground

by Cath_kb

HTML

<div class="illustration">
    <img src="" width="150" height="100" />
    <span>Подпись1</span>

</div>
<div class="illustration">
    <img src="" width="80" height="120" />
    <span>Подпись2 какая-то очень длинная, не просто так</span>
</div>

CSS

.illustration {
    display:inline-block;
    text-align:center;
    vertical-align:top;
    border: 1px solid;
}
img {
    display: block;
    background: red;            
}

JavaScript

$(window).load(function(){
    jQuery.each($('.illustration'), function(i, val) {
        $(this).css({'width' : $(this).children('img').width()});
    });
});