-
-
Save bdelespierre/c8046e7d61cf13904004dda8d3a42c0e to your computer and use it in GitHub Desktop.
A jquery typography plugin.
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
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(function(){ | |
$('.hsjs').hatchShow(); | |
}); | |
(function($){ | |
jQuery.fn.hatchShow = function(){ | |
return $(this).css({ | |
display: 'inline-block', | |
whiteSpace: 'pre' | |
}).each(function(){ | |
var parent = $(this).parent(), | |
fontSize = parseInt($(this).css('font-size').replace('px', '')), | |
maxWidth = parent.width() - (parent.outerWidth(true) - parent.width()); | |
while ($(this).outerWidth(true) < maxWidth) { | |
$(this).css('font-size', ++fontSize); | |
} | |
while ($(this).outerWidth(true) > maxWidth) { | |
$(this).css('font-size', --fontSize); | |
} | |
}) | |
} | |
})(jQuery); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
demo: