jquery实现弹出层完美居中效果
2018-10-12 14:06
645 查看
jquery实现弹出层完美居中效果
showDiv($("#pop"));
function showDiv(obj){
$(obj).show();
center(obj);
$(window).scroll(function(){
center(obj);
});
$(window).resize(function(){
center(obj);
});
}function center(obj){
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $(obj).height();
var popupWidth = $(obj).width();
$(obj).css({
"position": "absolute",
"top": (windowHeight-popupHeight)/2+$(document).scrollTop(),
"left": (windowWidth-popupWidth)/2
});
}
您可能感兴趣的文章:
相关文章推荐
- jquery实现弹出层完美居中效果
- jQuery实现弹出带遮罩层的居中浮动窗口效果
- 使用jquery实现弹出窗口效果(居中、左下角、右下角)
- 使用jquery实现弹出层效果
- 纯JavaScript实现的完美渐变弹出层效果代码
- jquery实现简单实用的弹出层效果代码
- jquery插件 弹出层的效果实现代码
- jQuery实现的向上弹出的仿flash效果的导航菜单
- jquery弹出层完美居中
- jQuery实现的浮动层div浏览器居中显示效果
- 用jquery实现弹窗居中、居左、居右显示的效果(完全代码,可立即使用)
- jQuery实现弹窗居中效果类似alert()
- jQuery实现的自定义弹出层效果实例详解
- jQuery实现单击按钮遮罩弹出对话框效果(2)
- jQuery实现文章图片弹出放大效果
- jquery实现弹出窗口效果的实例代码
- Jquery实现弹出层分享微博插件具备动画效果
- jquery 实现弹出层效果
- jQuery实现简单网页遮罩层/弹出层效果兼容IE6、IE7
- Jquery实现弹出层分享微博插件具备动画效果