I'm a jQuery plugin.
I change a font size to fill a container.

Type something...

how to use

include jQuery and myself

<script src="jquery.min.js"></script>
<script src="jquery.textfill.min.js"></script>

mark the element I'll expand

<div id="my-element" style="width:100px; height:50px;">
    <span>My awesome text!</span>
</div>

Note: make sure to put the text inside of a child span and
specify the parent's width and height

initialize me

$('#my-element').textfill({
    ...options...
});

options

Name Description Default
minFontPixels Minimal font size (in pixels) 4
maxFontPixels Maximum font size the text could resize (in pixels). For size <= 0, the text is sized to as big as the container can accommodate. 40
innerTag The child element tag to resize. span
widthOnly only resizing for width restraint false
explicitWidth explicit width null
explicitHeight explicit height null
changeLineHeight Also change the line-height of the parent container. This might be useful when shrinking to a small container. false
allowOverflow Allows text to overflow when minFontPixels is reached. Won't fail resizing, but instead will overflow container. false
debug Output debugging messages to console false

callbacks

name called when... default
success ...resizing is successful null
fail ...resizing just failed null
complete ...resizing finished null