angular.js - 在移动端web上如何解决输入法挡住文本框问题?
问题描述
在移动端web页面内定义了一个比较大的textarea大概能显示15行字,点击textarea的时候,输入法弹出来会遮住textarea下端的几行字,导致输入的字数到10行之后,后面的输入的字都被输入法挡住了,变成了盲打,体验很差。
请问使用js有什么方法可以解决这种问题?
刚刚写了个比较笨的方法,发现只有三星的手机以及android5.0能兼容,什么小米,vivo之类的乱七八糟的机子都不认这个方法,醉了。。
<textarea onfocus='textfocus(this)' onblur='textblur(this)' rows='' cols=''></textarea><script type=’text/javascript’> function textfocus(o){ o.style.position = ’fixed’; o.style.top = ’50px’; o.style.zIndex = ’999’; } function textblur(o){ o.style.position = ’static’; o.style.top = ’auto’; } </script>
问题解答
回答1:1.当textarea接收到focus事件时,自动将文本框滚动到屏幕顶端2.设计的输入框不要超过半个屏幕,如果一定要超过,textarea有change事件,计算输入了多少个字,相应的再把输入框向上滚动
这样应该就能很友好了
回答2:使用fixed定位,bottom
相关文章:
1. angular.js - angularjs 使用鼠标悬停时,标签一直闪2. angular.js - angularjs directive怎么实现通过点击事件更换模版?3. html5 - 只用CSS如何实现input框的宽度随框里输入的内容长短自动适应?4. angular.js - angular内容过长展开收起效果5. javascript - 求解答,koa-bodyparser获取到的参数是空对象,为什么?????6. html5 - 百度Ueditor代码高亮和代码段滚动条冲突是怎么回事?7. macos - mac下docker如何设置代理8. HTML 5输入框只能输入汉字、字母、数字、标点符号?正则如何写?9. angular.js - angularjs 与requirejs集成10. python2.7为什么点击了"开始"按钮后,tkinter上的按钮,图中红色部分,再也点不动了?