jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) +
$(window).scrollTop()) + "px");
this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) +
$(window).scrollLeft()) + "px");
return this;
}
Created
July 29, 2014 08:25
-
-
Save sgsheg/9123320a4486cbb619e3 to your computer and use it in GitHub Desktop.
make div center the screen jquery plugin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment