Created
February 8, 2020 10:07
-
-
Save akshuvo/b59ed41d32f1beea8a106733211d98d8 to your computer and use it in GitHub Desktop.
Auto Scale With Screen Size
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
// body auto scale | |
jQuery(document).ready(function($){ | |
if( window.outerWidth > 767 ){ | |
$(window).on('resize',function(){ | |
var baseW = 1920; | |
var docW = window.outerWidth; | |
var docH = $(document).height(); | |
var ePos = $('.footerend').position().top; | |
var marginB = Math.min(docH-ePos); | |
scale = Math.min(docW/baseW); | |
$('body').css({ | |
'-webkit-transform' : 'scale(' + scale + ')', | |
'-moz-transform' : 'scale(' + scale + ')', | |
'-ms-transform' : 'scale(' + scale + ')', | |
'-o-transform' : 'scale(' + scale + ')', | |
'transform' : 'scale(' + scale + ')' | |
}); | |
console.log(baseW,docW,scale); | |
}); | |
$(window).trigger('resize'); | |
} | |
// Windwo load | |
$(window).load(function(){ | |
if( window.outerWidth > 767 ){ | |
$(window).on('resize',function(){ | |
var docH = $(document).height(); | |
var ePos = $('.footerend').position().top; | |
var marginB = Math.min(docH-ePos); | |
$('body').css({ | |
'margin-bottom' : '-'+marginB+'px' | |
}); | |
}); | |
$(window).trigger('resize'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment