Quick Start Guide
Percentext brings traditional DOM arrangement to text-based elements, allowing developers and designers the ability to quickly, easily and responsively size headers to be 'just right' across devices.
Many people who find it irksome to deal with font sizes use FitText.js. FitText is a great little plugin, but it isn't quite the same as Percentext. FitText arbitrarily sets font-size to be equal to a fraction of the parent container's width, allowing users to tweak via a 'compressor' to get the size just right.
Percentext's advantage is that it allows you to set a percentage and be done with it—no tweaking required. It also lets you achieve some pretty cool effects, without much work. The downside to this convenience is performance; FitText is a very simple plugin that works lightning fast. Percentext is pretty quick too, but it can be a bit sluggish if you have many headers that you wish to size in preciseMode.
Easy! CD into your project directory, and run:
$bower install percentext
By default, bower installs packages into bower_components. If you haven't tinkered with the defaults, you can then include percentext like so:
If you're happy with the default settings, you can just call it on any element you want:
The default assumes you want the header's text to take up 100% of the width. If you want to specify a custom width, you can do so in the following ways:
There are a whole bunch of ways to customize Percentext to suit your needs (see below), but one more critical option to know about: Precise Mode.
Precise mode isn't happy to just grab the most appropriate font size, it uses letter spacing to try and match your requested width to the pixel. The downside is it can be pretty greedy with your CPU's cycles. If you're noticing the performance of Percentext leaves something to be desired, turn it off like so:
Percentext features a number of options that allow you to change how the plugin works. Most are pretty self-explanatory, but there are some pretty cool tweaks that might not be immediately obvious.
All currently-unfixed known issues are listed here:
This plugin released under the MIT open-source license. You can read all about it here, but the long and short of it is you can do pretty much whatever you want with this plugin, personal or commercial, as long as you give me credit and don't hold me liable for anything.
Are you using this plugin? I'd love to see what you've done with it! Please drop a line and let me know =)