Skip to content

Instantly share code, notes, and snippets.

@Robdel12
Last active December 21, 2015 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robdel12/6227091 to your computer and use it in GitHub Desktop.
Save Robdel12/6227091 to your computer and use it in GitHub Desktop.
Shrink the text size based on the container width.
$(document).ready(function(){
//Span that the text lives
$('.class-name').each(function(){
//Get the width of the span
var textWidth = $(this).width();
//If the width of the span is greater than 105px then run the if.
if(textWidth > 105){
//Your class that shrinks the the font size
$(this).addClass('graph-text-smaller');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment