-
-
Save jhampton/8032990 to your computer and use it in GitHub Desktop.
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 type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(window).load(function(){ | |
$().hatchShow(); | |
}); | |
jQuery.fn.hatchShow = function(){ | |
$('.hsjs').css('display','inner-block').css('white-space','pre').each(function(){ | |
var t = $(this); | |
t.wrap("<span class='hatchshow_temp' style='display:block'>"); | |
var pw = t.parent().width(); | |
while( t.width() < pw ){t.css('font-size', (t.fontSize()+1)+"px"), | |
function(){while( t.width() > pw ){t.css('font-size', (t.fontSize()-.1)+"px")}}; | |
}; | |
}).css('visibility','visible').css('display','block'); | |
}; | |
jQuery.fn.fontSize = function(){return parseInt($(this).css('font-size').replace('px',''));}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added "display:block" for IE8, otherwise, it works great! Thanks!