zoukankan      html  css  js  c++  java
  • h5底部输入框被键盘遮挡问题

    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

  • 相关阅读:
    文章索引
    Rancher pipeline 实现简单跟踪
    rancher 应用商店
    nginx ingress 在aks 上安装
    go countdown
    go channel pipeline 套路
    gorm使用
    华为云cce pvc 指定云硬盘云存储
    influxdb 基本概念
    Python3处理xlsx去掉含有特定字符的行
  • 原文地址:https://www.cnblogs.com/chenzxl/p/14945153.html
Copyright © 2011-2022 走看看