首页 > 其他 > 详细

h5底部输入框被键盘遮挡问题

时间:2021-06-28 19:36:12      阅读:50      评论:0      收藏:0      [点我收藏+]
winResize() 
function winResize() {
    // var oHeight=$(window).height();
    $(window).resize(function () {          //当浏览器大小变化时
        var // newHeight = $(window).height(),//窗口当前高度
            domNeedTop=90,//(oHeight-newHeight)/2,//40,//当前dom需要距离可视区域 顶部 高度
            domOffsetTop=$("input:focus").offset().top,//当前元素距离顶部高度;
            needScroll=domOffsetTop-domNeedTop;//滚动条需要向上滚动的距离
        $(html , body).animate({scrollTop: needScroll},slow);
    });
}

var getHeight = $(document).height();

$(window).resize(function(){
 if($(document).height() < getHeight) {
  $(#footer).css(position,static);
 }else {
  $(#footer).css(position,absolute);
 }
});

 

 

技术分享图片

 

 

 当键盘弹出时,键盘高度 = 不可见窗口高度

可视区域的中心位置 = 键盘高度 + (窗口高 - 键盘高度)/2
应滚动距离 = 可视区域的中心位置 - 光标offsetTop - (光标被遮挡 ?键盘高度 :0)

 

https://www.cnblogs.com/guolao/p/11936709.html

 

h5底部输入框被键盘遮挡问题

原文:https://www.cnblogs.com/chenzxl/p/14945153.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!