JSFiddle - React, Tailwind, and code Playground
by aldomatic
HTML
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<p>
<div class="photo"><img src="http://www.dmagazine.com/~/media/0_Articles/Web/2013/Jagr/Jagr_sticks_Dallas_Stars.ashx?db=master&20130404T1214577855" alt=""><div class="caption">Jágr cultivated a reputation as an arrogant, disengaged talent trying to squeeze every penny he could out of his career.<br><span class="ml_10 photocredit"><a href="#"> </a></span></div></div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<p>
<div class="photoright"><img src="http://www.dmagazine.com/~/media/0_Articles/Web/2013/Jagr/Jagr_headshot_Dallas_Stars.ashx?db=master&20130404T1217292752" alt=""><div class="caption">Jágr cultivated a reputation as an arrogant, disengaged talent trying to squeeze every penny he could out of his career.<br><span class="ml_10 photocredit"><a href="#"> </a></span></div></div>
<p> Last line Lorem Ipsum is simply dummy text of the printing and typesetting...
CSS
.photoright{border:solid red 1px;float:right;margin:20px;}
.photo{border:solid blue 1px;float:left;margin:20px;}
.caption{clear:both;padding:0 40px;}
JavaScript
$(function(){
$('.photo img, .photoright img').each(function(item, index) {
var theWidth = $(this).width();
var cap = $(this).parent().find(".caption")[0];
var paddingLeft = $(cap).css("padding-left");
var paddingRight = $(cap).css("padding-right");
theWidth = theWidth - parseFloat(paddingLeft) - parseFloat(paddingRight);
$(cap).css("width",theWidth);
});
});