Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Last active April 29, 2018 05:55
Show Gist options
  • Save andreasvirkus/6321ce095fe479fe5384735f1122fef7 to your computer and use it in GitHub Desktop.
Save andreasvirkus/6321ce095fe479fe5384735f1122fef7 to your computer and use it in GitHub Desktop.
/* Remember to add styles for the .caps class */
.caps {
font-size: 1.4em;
}
/* 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