Code Snippets

Custom jQuery for Fitting Website to Mobile Devices

This little trick can be used to fit websites into mobile screens. For more information refer to this blog post

$(window).load(function() {
  setImageSize();
});

$(window).resize(function() { 
  setImageSize(); 
});

function setImageSize() {
  $bodyHeight = $('body').outerHeight();
  $headerHeight = $('#header').outerHeight();
  $footerHeight = $('#footer').outerHeight();
  $imageHeight = $bodyHeight - $headerHeight - $footerHeight;
  $('#image').height($imageHeight); 

 

Resource Tags: