1.水平居中
.className{ margin:0 auto; width:200px; height:200px;}
2.垂直水平居中
.className{ width:300px; height:200px; position:absolute; left:50%; top:50%; margin:-100px 0 0 -150px;}
3.jquery实现水平垂直居中
$(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();