源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

jquery实现弹出层完美居中效果

  • 时间:2020-12-06 00:38 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:jquery实现弹出层完美居中效果
jquery实现弹出层完美居中效果
[u]复制代码[/u] 代码如下:
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    });  }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部