BoxBoy

Untitled

Apr 28th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. $(window).load(function() {
  2.  
  3. var theWindow = $(window),
  4. $bg = $("#bg"),
  5. aspectRatio = $bg.width() / $bg.height();
  6.  
  7. function resizeBg() {
  8.  
  9. if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
  10. $bg
  11. .removeClass()
  12. .addClass('bgheight');
  13. } else {
  14. $bg
  15. .removeClass()
  16. .addClass('bgwidth');
  17. }
  18.  
  19. }
  20.  
  21. theWindow.resize(resizeBg).trigger("resize");
  22.  
  23. });
Advertisement
Add Comment
Please, Sign In to add comment