, HTML, - :
var $container = $('#containerDiv');
for (var i = 0; i < data.length; i++)
{
$container.append(data[i]);
}
$container.children('div').textfill({ maxFontPixels: 36 });
, , <span>, HTML, , . wee little test, , , jQuery, . :
$container.children('div').each(function ()
{
$(this).textfill({ maxFontPixels: 36 });
});
" " - :
;(function($) {
$.fn.textfill = function(options) {
var fontSize = options.maxFontPixels;
this.each(function () {
var $this = $(this),
ourText = $this.find('span:visible:first'),
maxHeight = $this.height(),
maxWidth = $this.width(),
textHeight,
textWidth;
do {
ourText.css('font-size', fontSize);
textHeight = ourText.height();
textWidth = ourText.width();
fontSize = fontSize - 1;
} while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize > 3);
});
return this;
}
})(jQuery);
, , , div?
. ,
$container.children('div').each(function ()
{
$(this).textfill({ maxFontPixels: 36 });
});
$container.children('div').textfill({ maxFontPixels: 36 });