Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Resize fonts on a webpage to make things visible from a distance.
// Mark things you want to resize with class="resizeable"
// The ratio between their sizes will be maintained.
// works with jquery-1.4.2.min.js
//
// <script src=".../jquery-1.4.2.min.js"></script>
// <script src=".../resize.js"></script>
//
function resizeNodes(nodes, startsizes, multiplier){
var newsizes = startsizes.map(function(item, index){return item * multiplier;});
nodes.each(function(index){$(this).css('font-size',newsizes[index]);});
};
function resize() {
var multiplier = 1.0;
var nodes = $(".resizeable");
var startsizes = nodes.map(function(){return parseFloat($(this).css('font-size'),10);}).get();
while ($(document).height()<=($(window).height()))
{
multiplier += 0.5;
resizeNodes(nodes, startsizes, multiplier);
};
while ($(window).height()<$(document).height()&& multiplier > 0.5)
{
multiplier -= 0.01;
resizeNodes(nodes, startsizes, multiplier);
};
while ($(window).width()<$(document).width() && multiplier > 0.5)
{
multiplier -= 0.05;
resizeNodes(nodes, startsizes, multiplier);
};
};
$(document).ready(resize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.