TextTailor.JS
TextTailor
Tailor-made text to fit your needs!
Responsive text to fill the height of the parent element or ellipse it when it doesn't fit.
Download from GitHub

Examples

Fit the box

Crawling to the limit of my chain, I found that by reaching one hand as far out as I could my fingers still fell an inch short of the coveted instrument.
$('.box').textTailor();

News / Posts

Post not justified

Crawling to the limit of my chain, I found that by reaching one hand as far out as I could my fingers still fell an inch short of the coveted instrument. It was tantalizing! Stretch every fiber of my being as I would, I could not quite make it. At last I turned about and extended one foot toward the object. My heart came to my throat! I could just touch the thing! But suppose that in my effort to drag it toward me I should accidentally shove it still farther away and thus entirely out of reach! Cold sweat broke out upon me from every pore. Slowly and cautiously I made the effort. My toes dropped upon the cold metal. Gradually I worked it toward me until I felt that it was within reach of my hand and a moment later I had turned about and the precious thing was in my grasp. Assiduously I fell to work upon the Mahar lock that held my chain. It was pitifully simple. A child might have picked it, and a moment later I was free. The Mahars were now evidently completing their work at the table. One already turned away and was examining other victims, evidently with the intention of selecting the next subject. Those at the table had their backs toward me. But for the creature walking toward us I might have escaped that moment. Slowly the thing approached me, when its attention was attracted by a huge slave chained a few yards to my right. Here the reptile stopped and commenced to go over the poor devil carefully, and as it did so its back turned toward me for an instant, and in that instant.

Post with Image

"And your master is—" "He stayed on board." "But he must go to the consul's in person, so as to establish his identity." "Oh, is that necessary?" "Quite indispensable." "And where is the consulate?" "There, on the corner of the square," said Fix, pointing to a house two hundred steps off. "I'll go and fetch my master, who won't be much pleased, however, to be disturbed." The passenger bowed to Fix, and returned to the steamer. The detective passed down the quay, and rapidly made his way to the consul's office, where he was at once admitted to the presence of that official. "Consul," said he, without preamble, "I have strong reasons for believing that my man is a passenger on the Mongolia." And he narrated what had just passed concerning the passport. "Well, Mr. Fix," replied the consul, "I shall not be sorry to see the rascal's face; but perhaps he won't come here—that is, if he is the person you suppose him to be. A robber doesn't quite like to leave traces of his flight behind him; and, besides, he is not obliged to have his passport countersigned." "If he is as shrewd as I think he is, consul, he will come." "To have his passport visaed?" "Yes. Passports are only good for annoying honest folks, and aiding in the flight of rogues. I assure you it will be quite the thing for him to do; but I hope you will not visa the passport." "Why not? If the passport is genuine I have no right to refuse." "Still, I must keep this man here until I can get a warrant to arrest him from London."

Fixed font justified

"And your master is—" "He stayed on board." "But he must go to the consul's in person, so as to establish his identity." "Oh, is that necessary?" "Quite indispensable." "And where is the consulate?" "There, on the corner of the square," said Fix, pointing to a house two hundred steps off. "I'll go and fetch my master, who won't be much pleased, however, to be disturbed." The passenger bowed to Fix, and returned to the steamer. The detective passed down the quay, and rapidly made his way to the consul's office, where he was at once admitted to the presence of that official. "Consul," said he, without preamble, "I have strong reasons for believing that my man is a passenger on the Mongolia." And he narrated what had just passed concerning the passport. "Well, Mr. Fix," replied the consul, "I shall not be sorry to see the rascal's face; but perhaps he won't come here—that is, if he is the person you suppose him to be. A robber doesn't quite like to leave traces of his flight behind him; and, besides, he is not obliged to have his passport countersigned." "If he is as shrewd as I think he is, consul, he will come." "To have his passport visaed?" "Yes. Passports are only good for annoying honest folks, and aiding in the flight of rogues. I assure you it will be quite the thing for him to do; but I hope you will not visa the passport." "Why not? If the passport is genuine I have no right to refuse." "Still, I must keep this man here until I can get a warrant to arrest him from London."
// just ellipse it
$('.fixed').textTailor({
	fit: false
});
$('.fixedJustify').textTailor({
	fit: false,
	justify: true
});

Options Available

$('.tailorMe').textTailor({
	minFont: 1, 		// minimum font (use with fit: true)
	maxFont: 9999, 		// maximum font (use with fit: true)
	preWrapText: false,	// adds css -> white-space: pre-line
	lineHeight: 1.45, 	// line-height property
	resizable: true, 	// tailor again on window resize
	debounce: false, 	// use with resizable: true
	fit: true,  		// fit the text to the parent's height and width
	ellipsis: true, 	// ellipsis the text if it doesn't fit
	center: false, 		// absolute center relatively to the parent
	justify: false 		// adds css -> text-align: justify
});
Fork me on GitHub