Last active
November 13, 2015 15:41
-
-
Save wmeredith/4d0f932334a641f4c797 to your computer and use it in GitHub Desktop.
Center an element with jquery
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
$('#element').ready(function() { | |
$(this).css({ | |
'position' : 'absolute', | |
'left' : '50%', | |
'top' : '50%', | |
'margin-left' : -$('#element').outerWidth()/2, | |
'margin-top' : -$('#element').outerHeight()/2 | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment