FontStretch adjusts the size of text to fit within its containing element.
HTML:
<!DOCTYPE html>
<html>
<head>
<title>FontStretch</title>
</head>
<body>
<div class="tagline">The quick brown fox...</div>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript" src="jquery.fontstretch.js"></script>
</body>
</html>
JS:
$('.tagline').fontStretch();
Option | Default | Description |
---|---|---|
width | null | Optional. Fit the text element within the specified size in pixels. Otherwise, grab the width of the element. |
sizeLimit | 999 | Optional. Limits the maximum font size to the specified value. |
sizeOffset | 1 | Optional. Start calculating font sizes from the specified value. |
sizeIncrement | 1 | Optional. Increment with the specified value while calculating the font size, useful for bigger fonts to reduce the number of loops. |