Skip to content

Instantly share code, notes, and snippets.

View ronaldroe's full-sized avatar

Ronald Roe ronaldroe

View GitHub Profile
@ronaldroe
ronaldroe / pmft.js
Last active August 29, 2015 14:09
The Poor Man's FitText
/* Requires jQuery
** Include this file or copy/paste into your document.
** Call the function, passing the selector as a jQuery-style string.
** Offset is a number used to keep the text just short of the width of the parent to avoid rounding errors that will wrap the text.
** You can use the offset to adjust how close you want the width to be. Offset is optional and defaults to 10.
** Step defines the increase in font size. If you find one or more of your elements pushes out further than the others, adjust this
** number.
** For this to work, the element containing the text must be set to display:inline or inline-block, and the parent should be anything
** other than inline. So, if you have an h1 inside a header, you will need to make sure the h1 is inline or inline-block and the header
** isn't inline.