ios 底部用定位 fixed。在软件盘出来后,页面元素被顶上去一部分,fixed定位的footer也跑到了上面去。解决方法

ios 底部用定位 fixed。在软件盘出来后,页面元素被顶上去一部分,fixed定位的footer也跑到了上面去。解决方法


$("input").focus(function(){
        $('.footerssss').css({
            'position':'absolute'
        })
    })
    $("input").blur(function(){
        $('.footerssss').css({
            'position':'fixed'
        })
        setTimeout(function() {
            var scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
            window.scrollTo(0, Math.max(scrollHeight - 1, 0));
        }, 300);
    })

  思路:

input或者textarea 在用户获取焦点的时候,底部定位的元素 fixed变为absolute,

在input失去焦点的时候,底部定位元素 再变成 fixed。再让页面滚动一下,让顶上去的一部分元素,回来。

猜你喜欢

转载自www.cnblogs.com/gaidalou/p/10755550.html