Truncates the text nodes of elements to fit inside a container
var myFitText = new FitText(container, elements, options);
mixed) A string of the id for an Element or an Element reference to contain the text nodes width.mixed) A string of the selector for a group of Elements or an array of Elements to be truncated.object: optional) See below:number: defaults to 10) Subtracted from the container size to determine how long a line of text needs to be before truncating it. If you have truncated text extending beyond your container, increase this number.string: defaulst to truncated) A CSS class name added to truncated elements.<ul id="container">
<li><span>Lorem ipsum dolor</span></li>
<li><span>sit amet, consectetur adipisicing</span></li>
<li><span>elit, sed do eiusmod tempor incididunt ut labore et</span></li>
</ul>
ul {
list-style: none;
width: 50%;
}
li {
white-space: nowrap;
}
var myFitText = new FitText('container','li > span',{
offset: 20,
fitClass: 'fitted'
});
Your elements must have have display: inline in order to work.
Truncates all the elements to fit inside the container
myFitText.fit();
This FitText instance.
Attaches a resize event to the window, upon which the method fit is called.
myFitText.attach();
This FitText instance.
Removes the resize event from the window.
myFitText.detach();
This FitText instance.
Sets the text nodes back to their original values.
myFitText.reset();
This FitText instance.