Last active
December 21, 2015 01:19
-
-
Save Robdel12/6227091 to your computer and use it in GitHub Desktop.
Shrink the text size based on the container width.
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
$(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