您的位置:首页 > 移动开发

移动端解决fixed和input获取焦点软键盘弹出影响定位的问题

2018-03-02 16:55 741 查看
1.html和css就不写了,就是某个固定在页面底部的div,当在苹果手机UC浏览器和安卓手机浏览器打开web H5页面时,页面中的input获取焦点后,固定于底部的div会出现在软键盘上方,影响布局,解决方法如下:
            $(function(){
$('.school-body input').bind('focus',function(){  
   $('.sure-btn').css('position','static');  
   //或者$('#viewport').height($(window).height()+'px');  
}).bind('blur',function(){  
   $('.sure-btn').css({'position':'fixed','bottom':'0'});  
   //或者$('#viewport').height('auto');  
});  
})

解决屏幕旋转也会出现以上问题:

            $(document).bind('orientationchange',function(){  
            if(window.orientation==90 || window.orientation==-90){  
                $('.bottom_fix').css('position','static');  
            }else{  
                $('.bottom_fix').css({'position':'fixed','bottom':'0'});  
            }  

        });

参考网址:http://blog.csdn.net/kongjiea/article/details/46545351
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐