Skip to content

Instantly share code, notes, and snippets.

@nrrrdcore
Created June 26, 2013 03:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nrrrdcore/5864551 to your computer and use it in GitHub Desktop.
Save nrrrdcore/5864551 to your computer and use it in GitHub Desktop.
Text-Align: Justify; Hack
<p class="month"><span class="name">July</span> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31<span class="break">hi</span></p>
.month {
text-align: justify;
.break {
display: inline-block;
width: 100%;
color: transparent;
}
}
@nrrrdcore
Copy link
Author

The text-align: justify; hack is pretty smart. It allows you to justify the text of an inline element given whatever width it's served. It's flexy. Here's the article that Barrel NY put out about it. And here's an example of how I'm using it to justify the days of the month on this calendar-type-thing:

screen shot 2013-06-25 at 8 38 31 pm

When I change the width of the element, the space between words automagically evens out. Which is coincidentally super useful if I wanted to change the number of days in the month/ alternate without hand coding spans around each date.

Automate all the things!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment