Skip to content

Instantly share code, notes, and snippets.

@rambuvn
Created April 14, 2016 08:08
Show Gist options
  • Save rambuvn/a060f3003294aa815f4f48b549e8ce69 to your computer and use it in GitHub Desktop.
Save rambuvn/a060f3003294aa815f4f48b549e8ce69 to your computer and use it in GitHub Desktop.
$('.stretch-text').each(function(index, el) {
var line = $(el);
line.html('<span class="stretch-it">'+line.text()+'</span>');
var text = line.find('.stretch-it' );
var textLength = line.text().length,
textWidth = text.width();
var spacing = line.width() - textWidth;
var lt_spacing = spacing / textLength;
line.css('letter-spacing', lt_spacing + 'px' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment