Skip to content

Instantly share code, notes, and snippets.

Embed
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
@iamkirkbater

This comment has been minimized.

Copy link

iamkirkbater commented Aug 6, 2014

@LinuxRocks2000

This comment has been minimized.

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
You can’t perform that action at this time.