手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery实现弹出层完美居中效果
jquery实现弹出层完美居中效果
摘要:jquery实现弹出层完美居中效果复制代码代码如下:showDiv($("#pop"));functionshowDiv(obj){$(ob...

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插件bgStretcher.js实现全屏背景特效

jquery实现弹出层效果实例

jquery实现图片左右切换的方法

jQuery实现文本展开收缩特效

javascript实现删除前弹出确认框

JS+DIV实现鼠标划过切换层效果的方法

jQuery实现表格行上下移动和置顶效果

JavaScript实现广告的关闭与显示效果实例

js实现顶部可折叠的菜单工具栏效果实例

精品推荐
分类导航