Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
I wrote this simple function in CoffeeScript which tests if the text overflow the div and it will decrement his size until it fits!
autoSizeText = ->
elements = $('.resize')
return if elements.length < 0
for el in elements
do (el) ->
resizeText = ->
elNewFontSize = (parseInt($(el).css('font-size'), 10) - 1)
$(el).css('font-size', elNewFontSize)
resizeText() while el.scrollHeight > el.offsetHeight
Copy link

iamkirkbater commented Aug 6, 2014

Copy link

LinuxRocks2000 commented Jul 10, 2018

how to implement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment