Skip to content

Instantly share code, notes, and snippets.

@0xnbk
Created September 13, 2010 04:18
Show Gist options
  • Save 0xnbk/576801 to your computer and use it in GitHub Desktop.
Save 0xnbk/576801 to your computer and use it in GitHub Desktop.
Font resizing
$(document).ready(function(){
// Reset Font Size
var originalFontSize = $('html').css('font-size');
$(".resetFont").click(function(){
$('html').css('font-size', originalFontSize);
});
// Increase Font Size
$(".increaseFont").click(function(){
var currentFontSize = $('html').css('font-size');
var currentFontSizeNum = parseFloat(currentFontSize, 10);
var newFontSize = currentFontSizeNum*1.2;
$('html').css('font-size', newFontSize);
return false;
});
// Decrease Font Size
$(".decreaseFont").click(function(){
var currentFontSize = $('html').css('font-size');
var currentFontSizeNum = parseFloat(currentFontSize, 10);
var newFontSize = currentFontSizeNum*0.8;
$('html').css('font-size', newFontSize);
return false;
});
});
@0xnbk
Copy link
Author

0xnbk commented Sep 13, 2010

Font resizing

Font Resizing is a very common feature in many modern websites. Here’s how to do it with JQuery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment