手机
当前位置:查字典教程网 >编程开发 >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仿gmail实现fixed布局的方法

Jquery注册事件实现方法

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

jQuery实现的多屏图像图层切换效果实例

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

纯javascript实现四方向文本无缝滚动效果

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

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

jQuery结合ajax实现动态加载文本内容

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

精品推荐
分类导航