当屏幕底部的输入字段具有焦点时,键盘会向上推动我的webview,并且页面的上半部分不再可见.
我想阻止键盘推高webview.
有人有想法吗?
解决方法
在焦点上,设置window.scrollTo(0,0);这可以防止键盘完全推送webview
$('input').on('focus',function(e) { e.preventDefault(); e.stopPropagation(); window.scrollTo(0,0); //the second 0 marks the Y scroll pos. Setting this to i.e. 100 will push the screen up by 100px. });
如果您不想为Y滚动位置设置静态值,请随意使用此short plugin I’ve written that automatically aligns the keyboard underneath the input field.它并不完美,但它可以完成工作.只需在焦点上调用它,如上所示:
setKeyboardPos(e.target.id);