Created
January 5, 2017 22:27
-
-
Save alex-boom/30e093f925e8c2b207d74b4b7d5a9e7f to your computer and use it in GitHub Desktop.
center-element
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
var heightBody = $('body').height(); | |
var heightBlock = $('.block').height(); | |
var calc = heightBlock - heightBody; | |
var result = calc / 2; | |
$('.block') | |
.css({ | |
marginTop: result + 'px', | |
marginBottom: result + 'px' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment