Created
May 23, 2012 01:50
-
-
Save jimmynotjim/2772797 to your computer and use it in GitHub Desktop.
Simple Clean JS script to create Faux Small Caps
This file contains 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
I needed to create some faux small caps that were only slightly smaller than the full cap. Font-variant was too drastic so instead I wrapped each word in a <span> set the span to inline-block and used :first-letter to increase the font-size of the first letter in each word. |
This file contains 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
var spanWrap = document.getElementsByClassName('sm-cap'); | |
for(var i=0; i < spanWrap.length; i++) { | |
var t = spanWrap[i]; | |
t.innerHTML = '<span>' + t.innerHTML . split(' ') . join('</span> <span>') + '</span>'; | |
} |
This file contains 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
.sm-cap { | |
text-transform: uppercase; | |
} | |
.sm-cap span { | |
display: inline-block; | |
} | |
.sm-cap span:first-letter { | |
font-size: 1.2em; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment