Last active
January 8, 2018 21:15
-
-
Save farnscosnippet/475faafc5704498a6a13 to your computer and use it in GitHub Desktop.
JQUERY - Horizontal and Vertical Centering
This file contains hidden or 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
| $(window).resize(function(){ | |
| $('.className').css({ | |
| position:'absolute', | |
| left: ($(window).width() - $('.className').outerWidth())/2, | |
| top: ($(window).height() - $('.className').outerHeight())/2 | |
| }); | |
| }); | |
| // To initially run the function: | |
| $(window).resize(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment