I have the following CSS settings:
.header_wrapper, .navbar_wrapper, .body_wrapper, .footer_wrapper {
display: table;
width: 768px;
margin-left: auto;
margin-right: auto;
}
How can I resize these elements in increments (up until 100% of the browser window) to fit the text when the user clicks on the font-resize button? My font-size at default is 16px. When the user increases the font at this stage then the elements need to be resized (i.e. on page load). However when the user sizes down to 16px (and anything below it) then the default sizes should be restored.
Here is my JavaScript code:
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;
});
48em? Which is768px / 16px). Then the div will scale as the pages font size changes. This might help: css-tricks.com/why-ems - You don't need to use JavaScript to resize both. - Olical