Created
July 19, 2012 13:57
-
-
Save jcutrell/3144098 to your computer and use it in GitHub Desktop.
Centered text with letter-spacing fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requires jQuery | |
$("h2").each(function(){ | |
var h2 = $(this); | |
var t = h2.text(); | |
var last = t.split("")[t.length-1]; | |
var newtext = t.substring(0,t.length-1) + "<span style='letter-spacing:0px;'>" + last + "</span>"; | |
h2.html(newtext); | |
}); | |
// if h2 has letter-spacing > 0 and text-align:center applied in css, this function will remove the letter spacing on the last letter, which fixes the issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment