Last active
June 18, 2019 03:23
-
-
Save dansheffler/2f5bef7ad193cfb01a2a to your computer and use it in GitHub Desktop.
Style Blockquotes based on Wordcount
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
<script src="/js/jquery-1.8.3.min.js"></script> | |
// A little clever jQuery styling of blockquotes | |
<script> | |
$('blockquote p').each(function(){ | |
var $numWords = $(this).text().split(" ").length; | |
console.log($numWords) | |
if ($numWords >= 25) { | |
$(this).css("text-align", "left"); | |
$(this).css("padding-left", "1em"); | |
} | |
else { | |
$(this).css("font-size", "1.3em"); | |
} | |
if ($numWords >= 50) { | |
$(this).css("font-size", "0.7em"); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment