Home › Forums › JavaScript › jQuery Vertically Center Content › Re: jQuery Vertically Center Content
May 21, 2012 at 3:09 am
#103173
Taufik Nurrohman
Participant
$(document).ready( function() {
var $img = $('img');
$img.css({
'display': 'block',
'position': 'absolute',
'top': $(window).height()/2,
'left': $(window).width()/2,
'margin-left': '-' + ($img.width() / 2) + 'px',
'margin-top': '-' + ($img.height() / 2) + 'px'
});
});
Edit: I just missed the quotes