手机
当前位置:查字典教程网 >编程开发 >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实现的多屏图像图层切换效果实例

jQuery实现仿腾讯微博滑出效果报告每日天气的方法

Jquery注册事件实现方法

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

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

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

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

js实现异步循环实现代码

js实现带按钮的上下滚动效果

精品推荐
分类导航