jquery实现弹出层完美居中效果
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+CSS3实现一款简洁大气带滑动效果的弹出层
jquery ui dialog实现弹窗特效的思路及代码
jquery实现居中弹出层代码
jQuery弹出窗口完整代码(居中,居左,居右)
Jquery 弹出窗口居中效果的实现代码
基于jquery实现的一个选择中国大学的弹框 (数据、步骤、代码)
【精品推荐】web开发人员应该知道的31个jQuery模态对话框
css实现在div水平垂直居中与图片水平居中的效果