Guest User

Untitled

a guest
Sep 12th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. Find out the effective width of element and resize text in it
  2. <table><tr><td id=txtcell nowrap><span id=txt>My long text is long. My long text.</span></td></tr></table>
  3. <br>Font Size : <span id=mes></span>​
  4.  
  5. #txtcell{ max-width:200px;}
  6.  
  7. var fontSize = 20;
  8. var reduce = function() {
  9. while ($('#txt').width() > 200) {
  10. fontSize -= 1;
  11. $('#txt').css('font-size', fontSize);
  12. }
  13. $('#mes').html(fontSize); // this line is only for demonstration, remove it in "production"
  14. };
  15. reduce();
  16.  
  17. td {width: expression(this.style.width);}
Add Comment
Please, Sign In to add comment