JSFiddle - React, Tailwind, and code Playground
by zephod
HTML
<div class="title" id="one">
This is what I want to achieve with your help
</div>
CSS
#one {
width: 380px;
background: #ccc;
padding: 10px;
font-size: 30px;
}
JavaScript
$(function() {
$(".title").each(function(i,title) {
var width = 0;
var originalHeight = $(title).height();
var spacer = $('<div style="float:right;height:1px;"/>').prependTo(title);
while (originalHeight == $(title).height()) {
spacer.width( ++width );
}
spacer.width( --width );
});
});