YOCKBOX
var bg = ["https:\/\/www.yockbox.net\/wp-content\/uploads\/2013\/06\/s26_10931.jpg","https:\/\/www.yockbox.net\/wp-content\/uploads\/2013\/06\/bg10.jpg","https:\/\/www.yockbox.net\/wp-content\/uploads\/2013\/06\/bg006.jpg","https:\/\/www.yockbox.net\/wp-content\/uploads\/2013\/06\/bggg.jpg","https:\/\/www.yockbox.net\/wp-content\/uploads\/2013\/06\/bg000.jpg"]; $('body').css('background-image','url('+ bg[Math.floor(Math.random()*all_bg)] +')'); var bg_width = 1920; var bg_height = 1024; if($(window).width() <= 1920){ var bg_side = (1920 - jQuery(window).width() )/2; } var bg_top = ($(window).height() - bg_height)/2; var bg_left = ($(window).width() - bg_width)/2; console.log($(window).height()); $('body').css('background-position',bg_left+'px '+bg_top+'px'); var body_top = $(window).height()/2 - $('section#intro').height()/2; $('section#intro').css('top',body_top+'px'); $(window).resize(function() { if($(window).width() <= 1920){ var bg_side = (1920 - jQuery(window).width() )/2; } var bg_top = ($(window).height() - bg_height)/2; var bg_left = ($(window).width() - bg_width)/2; console.log($(window).height()); $('body').css('background-position',bg_left+'px '+bg_top+'px'); var body_top = $(window).height()/2 - $('section#intro').height()/2; $('section#intro').css('top',body_top+'px'); }); });