I would like to vertically center my main content div. I开发者_StackOverflow社区 am open to using jQuery and/or CSS, but I'd prefer avoiding an extra wrapper div tag.
What do I need to do to do?
jQuery:
$(document).ready(function() {
$('#main').css('position', 'relative');
$('#main').css('top', (($('#main').parent().height() - $('#main').height()) / 2) + "px");
});
This question is basically the same as this one, which recommends the following article.
http://www.jakpsatweb.cz/css/css-vertical-center-solution.html
精彩评论