Created
September 3, 2010 07:29
-
-
Save paranoidxc/563548 to your computer and use it in GitHub Desktop.
jQuery fn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.center_v = function () { | |
this.css("position","absolute"); | |
this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px"); | |
return this; | |
} | |
jQuery.fn.center_h = function () { | |
this.css("position","absolute"); | |
this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px"); | |
return this; | |
} | |
jQuery.fn.center = function () { | |
this.css("position","absolute"); | |
this.center_v(); | |
this.center_h(); | |
this.css("z-index","1000101"); | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment