text-fitter
Pure javascript implementation that fixes any content to fit the element. View demo.
Before | After |
You should use this project if ...
Any kind of layouting should be done (if possible) in CSS. If the performance of your site is important, use this project only to a limited extend. Try to use relative fonts wherever possible. This project might be interesting for you if you are trying to layout unknown content or for small effects.
Quickstart
Install the package with
npm install text-fitter --save
ES7
;const elements = document;; // elements can be an array or html list
VanillaJS
Disable font enlargement
If the content is too small to fill the entire element, content is enlarged. This is set by default.
Before | After |
To disable set second parameter to false:
; // elements can be an array or html list
The second parameter is optional and is set by default to false.