Last active
April 29, 2018 05:55
-
-
Save andreasvirkus/6321ce095fe479fe5384735f1122fef7 to your computer and use it in GitHub Desktop.
See the example: https://jsfiddle.net/andreasvirkus/1ouLxxo8/1/
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
/* Remember to add styles for the .caps class */ | |
.caps { | |
font-size: 1.4em; | |
} |
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
/* When using an all-caps font that doesn't support capitalised letter sizes, do this! */ | |
function smallCaps() { | |
var elements = document.querySelectorAll('.small-caps') | |
Array.prototype.forEach.call(elements, function(e) { | |
var text = e.innerHTML.toUpperCase() | |
e.innerHTML = text.replace(/\b([A-Za-z0-9])/g, '<span class="caps">$1</span>') | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment