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
});
}

web前端与移动开发 移动平台4g手机网站前端开发布局技巧汇总2018 移动端前端开发

赞(0)
前端开发者 » jQuery弹出层完美居中
64K

评论 抢沙发

评论前必须登录!