手机
当前位置:查字典教程网 >编程开发 >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实现表格行上下移动和置顶效果

javascript实现动态改变层大小的方法

jQuery实现延迟跳转的方法

js操作css属性实现div层展开关闭效果的方法

jQuery实现文本展开收缩特效

jQuery仿gmail实现fixed布局的方法

js实现异步循环实现代码

jQuery实现转动随机数抽奖效果的方法

jQuery实现首页图片淡入淡出效果的方法

精品推荐
分类导航