BigText Makes Text Big
I like shortcuts: Fork BigText on Github or Check out the BigText Demo Wizard
It all began with a simple web foray to Designing Monsters. Their simple, typographic design was beautiful. But why? Their combination of the beautiful League Gothic font, use of Lettering.JS, and some simple font scaling gave the page a wonderful consistent vertical alignment. Like the Million Dollar Homepage, I wanted to rebuild it — but I didn’t want to spend a lot of time manually adjusting font sizes. So I did what any programmer with the jQuery Golden Hammer would do, I turned my problem into a nail.
At its simplest, the BigText jQuery plugin takes a single element and sizes the text inside of its child <div>
s to fit the width of the parent element. Gives the text that lovely vertical alignment.
<div id="bigtext" style="width: 300px">
<div>The elusive</div>
<div>BIGTEXT</div>
<div>plugin exclusively</div>
<div>captured on film</div>
</div>
$('#bigtext').bigtext();
Implementation Details
The plugin itself is more than just a simple font-size incrementer. I wasn’t happy with the performance of simply iterating through font sizes with a single fixed interval. I decided it would be better to test multiple decreasing intervals. For each line, it increments first by 16em
until it detects a line break, backs off an interval then increments by 8em
. It continues with 4em
, 2em
, 1em
, 0
.1em
, until it finds the correct font-size to the nearest hundredth of an em. It’s noteworthy that Webkit does not respect font-sizes to the nearest hundredth, it’s precision is maxed out at tenths. This algorithm results in fewer tests in most cases, especially where the resulting font-size will be very large. Performance is always important. After font-size, it moves to word-spacing as a backup for extra precision, especially needed on Webkit.
The BigText Demo Wizard
This is where the magic happens.
- Editable text (
contenteditable
), and BigText will run on every keyup event to resize what you’re typing. - Dynamic horizontal and vertical centering using Alex Russell’s Flex Box CSS classes (This is easy now, hooray!)
- 3D transforms (browser support checked using Modernizr, currently only available in Safari. Note: Chrome flattens to 2D space)
- Custom fonts are loaded using Google’s Font Loader JavaScript API
- Ben Alman’s Throttle Plugin
- The rest is mostly jQuery UI with the Aristo theme
Turns out, the BigText Demo Wizard makes for really easy Kinetic Typography screencasts (not amazing, but surely easy):
The above is simply the manual process of typing lyrics into the BigText Demo Wizard. You can easily make one of these too, with the help of the following keyboard shortcuts:
- CTRL + ALT + X: Set the text to a random 3D transform angle.
- CTRL + ALT + C: Toggles between white and black background.
- CTRL + ALT + R: Reset 3D to default state.
- CTRL + ALT + SPACE: Fade out current text, clears the text, sets a random 3D transform angle, ready to type!
- CTRL + ALT + ENTER: Same as CTRL + ALT + SPACE, but keeps the same 3D transform angle.
The fun part about the BigText Demo Wizard for me was that it almost turned into a non-musical instrument when I used it real-time to complement music. Feel free to cruise Pandora and type lyrics to the music until your wrists get sore. What can you make with it?
The BigText Demo Wizard was tested manually in Safari 5, Chrome 8, Opera 11, Firefox 3.6, and Internet Explorer 8. The BigText jQuery plugin has a full JsTestDriver suite, available on GitHub. Just run ./test.sh or test.bat
76 Comments
@missninateaches
Ha! Some of my students were eight years old when you created it! It's the first result when I Google 'big text' and it does what I need it to do, so it's my go-to now. Thanks for sharing your work!
@zachleat
Awesome, this made my day—thank you for sharing
@zachleat
nothing like a super relevant post from 2011 😅 zachleat.com/web/bigtext-ma…
@raymondcamden
it's not really on topic but im curious - would this be doable via simple CSS now?
@davidrhoden
Well, I'll be.... I never made the connection you did this. I've been using BigText for years to make "flyers" for my friend's band. lukespurrallen.com/index.php?p=pa…
@zachleat
oh wow—those look incredible! 🏆
Cody Peterson Disqus
12 Jan 2011Schepp Disqus
12 Jan 2011Matt Disqus
12 Jan 2011Peter Michaels Allen Disqus
13 Jan 2011Dan L Disqus
13 Jan 2011SlowX Disqus
13 Jan 2011Anthony M Disqus
13 Jan 2011Rupesh Tiwari Disqus
13 Jan 2011josh Disqus
13 Jan 2011josh Disqus
13 Jan 2011Zach Leatherman Disqus
13 Jan 2011Zach Leatherman Disqus
13 Jan 2011Chris Papadopoulos Disqus
13 Jan 2011Johnboy Disqus
13 Jan 2011Zach Leatherman Disqus
14 Jan 2011Marina Disqus
14 Jan 2011Zach Leatherman Disqus
14 Jan 2011Jon Glick Disqus
14 Jan 2011Dan Rubin Disqus
17 Jan 2011Dan Rubin Disqus
17 Jan 2011Zach Leatherman Disqus
17 Jan 2011Adam Koch Disqus
19 Jan 2011Zach Leatherman Disqus
20 Jan 2011Andy Disqus
27 Jan 2011zeeshan Disqus
27 Jan 2011Dan L Disqus
31 Jan 2011brian Disqus
11 Feb 2011brian Disqus
11 Feb 2011Zach Leatherman Disqus
13 Feb 2011Zach Leatherman Disqus
13 Feb 2011Carl Disqus
22 Feb 2011Aaron @ iamcreative. Disqus
21 Sep 2011brian Disqus
27 Sep 2011Andrew Disqus
18 Nov 2011Zach Leatherman Disqus
18 Nov 2011Zane Disqus
20 Feb 2012Manus Sweeney Disqus
29 Mar 2012zachleat Disqus
27 Aug 2014Zach Leatherman Disqus
29 Mar 2012Shrihari Pandula Disqus
16 Jun 2012J Akerman Disqus
06 Sep 2012Zach Leatherman Disqus
07 Sep 2012Matt Disqus
07 Jul 2013zachleat Disqus
23 Jul 2013Sara Domini Disqus
10 Dec 2012lion Disqus
23 Jan 2013pawan Disqus
09 Sep 2013Yoochan Seo Disqus
24 Sep 2013Koder Disqus
18 Oct 2013Nick Disqus
21 Nov 2013Jack Rugile Disqus
10 Dec 2013shadowfax007 Disqus
20 Dec 2013zachleat Disqus
27 Dec 2013zachleat Disqus
27 Dec 2013bkhoo Disqus
17 Feb 2014Bojan Nisevic Disqus
28 Feb 2014Oscar clar Disqus
29 Mar 2014Daniel Disqus
16 May 2014mony Disqus
14 Jun 2014Tim Disqus
17 Jun 2014thecda Disqus
27 Aug 2014zachleat Disqus
27 Aug 2014Daric Disqus
15 Oct 2014zachleat Disqus
15 Oct 2014jaabaa Disqus
27 Oct 2014elshadianka Disqus
19 Jan 2015Jeez Louise Disqus
22 Feb 2015zachleat Disqus
28 Feb 2015Jeez Louise Disqus
06 Apr 2015Rory Troy Disqus
30 Mar 2015