var imgwidh=$('.img').width(); var screenwidth=document.documentElement.scrollWidth; $('.img').css({top:0;left:(screenwidth-imgwidh)/2});