Skip to content

Instantly share code, notes, and snippets.

@seoagentur-hamburg
Created April 18, 2013 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seoagentur-hamburg/5413240 to your computer and use it in GitHub Desktop.
Save seoagentur-hamburg/5413240 to your computer and use it in GitHub Desktop.
Das jQuery für die Lösung vollflächige Hintergrundbilder 3
$(window).load(function() {
var theWindow = $(window),
$bg = $("#bg"),
aspectRatio = $bg.width() / $bg.height();
function resizeBg() {
if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
$bg
.removeClass()
.addClass('bgheight');
} else {
$bg
.removeClass()
.addClass('bgwidth');
}
}
theWindow.resize(resizeBg).trigger("resize");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment