html - Javascript that automatically sets font-size on element so that text doesn't overflow? (autofit) -


Do you know what I mean? As we say:

  & lt; Div style = "width: 100px; font-size: 10px" & gt; Some text & lt; / Div & gt;  

But then we may also have a longer text string in that div, in that case I would like the div to have font-size: 7px or whatever, so that the entire string overflow Fits without

I'm sure something like that has already been written, I do not want to search it again. Preferably a jQuery plugin?

Any suggestions would be appreciated! Thanks

Based on the answer to the question of Nick:

  $ (Function () {$ (". ShrinkByWidth"). Each (function () {var targetWidth = $ (this) .Parent (': first') width (if; isNaN (parseInt ($ (this) ("Font-size")) $ (this) .css ("font-size", '24px'), while $ (this). Wide (target); {$ (this) .CSS ( "Font-size", (parseint ($ (this). Css ("font-size") - 1) + 'px');}}};});  

Works great for me!


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -