1.div水平居中
.className{
width:270px;
height:150px;
margin:0 auto;
} .className{
width:270px;
height:150px;
position:absolute;
left:50%;
top:50%;
margin:-75px 0 0 -135px;
}
3.适用jquery
$(document).ready(function(){
$(window).resize(function(){
$('.className').css({
position:'absolute',
left: ($(window).width()
- $('.className').outerWidth())/2,
top: ($(window).height()
- $('.className').outerHeight())/2
});
});
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/yangmingxing980/article/details/48008377