jquery实现水平垂直居中
2011-08-08 19:23
295 查看
jquery实现元相对于窗口水平垂直居中:
$(document).ready(function(){
$('.className').css({
position:'absolute',
left: ($(window).width() - $('.className').outerWidth())/2,
top: ($(window).height() - $('.className').outerHeight())/2 + $(document).scrollTop()
});
});
css实现元素水平垂直居中:
.class{
width:300px;
height:400px;
position:absolute;
left:50%;
top:50%;
margin:-200px 0 0 -150px;
}
$(document).ready(function(){
$('.className').css({
position:'absolute',
left: ($(window).width() - $('.className').outerWidth())/2,
top: ($(window).height() - $('.className').outerHeight())/2 + $(document).scrollTop()
});
});
css实现元素水平垂直居中:
.class{
width:300px;
height:400px;
position:absolute;
left:50%;
top:50%;
margin:-200px 0 0 -150px;
}
相关文章推荐
- jquery实现水平垂直居中
- jQuery实现DIV屏幕自动水平垂直居中
- 基于jQuery实现的水平和垂直居中的div窗口
- 基于jQuery实现的水平和垂直居中的div窗口
- jquery实现div水平垂直居中显示
- jQuery实现水平和垂直居中
- 安卓开发——实现canvas.drawText文字水平且垂直居中
- 使用CSS实现垂直水平居中
- jQuery垂直菜单和水平菜单实现
- CSS实现元素水平/垂直居中的方法
- 16种方法实现水平居中垂直居中
- CSS3实现水平垂直居中
- margin 实现水平居中,垂直居中原理
- 用jquery实现垂直左右居中
- jquery实现marquee效果(文字或者图片的水平垂直滚动)
- 盘点8种CSS实现垂直居中水平居中的绝对定位居中技术
- 实现div水平、垂直居中的几种方法
- CSS - 水平居中和垂直居中的多种实现方法
- Flexbox实现垂直水平居中
- 用CSS/CSS3 实现 水平居中和垂直居中的完整攻略