Created
September 9, 2015 14:40
-
-
Save felipevolpatto/4fa98f775fd9db6e0da0 to your computer and use it in GitHub Desktop.
Positioning an element at the center of the actual screen
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 = function () { | |
this.css("position","fixed"); | |
this.css("top", ($(window).height() / 2) - (this.outerHeight() / 2)); | |
this.css("left", ($(window).width() / 2) - (this.outerWidth() / 2)); | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment