ios 移动端 弹框用固定定位,获取弹框里面input的焦点,光标会乱跳

原创 韩秀利 随笔 css 148阅读 2018-06-08 08:49:47 举报

布局改为相对定位
var isOpen = 0;
$(".btnDel").click(function() {
center($(".box"));
});
function center(obj) {
var screenWidth = $(window).width(), screenHeigth = $(window).height();
var scollTop = $(document).scrollTop();
var objLeft = (screenWidth - obj.width()) / 2;
var objTop = (screenHeigth - obj.height()) / 2 + scollTop;
obj.css({
left:objLeft + "px",
top:objTop + "px"
});
obj.fadeIn(500);
isOpen = 1;
$(window).resize(function() {
if (isOpen == 1) {
screenWidth = $(window).width();
screenHeigth = $(window).height();
var scollTop = $(document).scrollTop();
objLeft = (screenWidth - obj.width()) / 2;
var objTop = (screenHeigth - obj.height()) / 2 + scollTop;
obj.css({
left:objLeft + "px",
top:objTop + "px"
});
obj.fadeIn(500);
}
});
$(window).scroll(function() {
if (isOpen == 1) {
screenWidth = $(window).width();
screenHeigth = $(window).height();
var scollTop = $(document).scrollTop();
objLeft = (screenWidth - obj.width()) / 2;
var objTop = (screenHeigth - obj.height()) / 2 + scollTop;
obj.css({
left:objLeft + "px",
top:objTop + "px"
});
obj.fadeIn(500);
}
});
}

评论 ( 0 )
最新评论
暂无评论

赶紧努力消灭 0 回复