muchisimas gracias: el código es este
html
Código HTML :
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Documento sin título</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script> <script src="size.js" ></script> <link rel="stylesheet" type="text/css" href="size.css"> </head> <body> <div class='container'> <div class='resize'><a href="#">This text will behgfh gfh dgfh g f the div.</a></div> </div> <script>autoSizeText();</script> </body> </html>
el Javascript
Código Javascript :
// JavaScript Document var autoSizeText; autoSizeText = function() { var el, elements, _i, _len, _results; elements = $('.resize'); console.log(elements); if (elements.length < 0) { return; } _results = []; for (_i = 0, _len = elements.length; _i < _len; _i++) { el = elements[_i]; _results.push((function(el) { var resizeText, _results1; resizeText = function() { var elNewFontSize; elNewFontSize = (parseInt($(el).css('font-size').slice(0, -2)) - 1) + 'px'; return $(el).css('font-size', elNewFontSize); }; _results1 = []; while (el.scrollHeight > el.offsetHeight) { _results1.push(resizeText()); } return _results1; })(el)); } return _results; }; autoSizeText(); // here is where we call the function.
el CSS
Código CSS :
/* CSS Document */ .resize { width: 970px; height: 120px; border: 1px solid #000; color: #000; float: left; margin-left: 10px; font-size: 100px; font-weight:bold; } .resize a{ color:#000; text-decoration:none;}
link para verlo:
http://unrespiro.com/resize