防止<输入>在iPhone上滚动屏幕的元素? [英] Preventing an <input> element from scrolling the screen on iPhone?

查看:238
本文介绍了防止<输入>在iPhone上滚动屏幕的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页上有几个< input type =number> 元素。我正在使用jQTouch,我一直想保持全屏;也就是说,水平滚动很糟糕。每当我点击< input> 元素时,页面会向右滚动,在屏幕右侧显示黑色边框并将所有内容置于中心位置。输入从屏幕左侧偏移,它们从页面中间的某处开始。

I have several <input type="number"> elements on my webpage. I'm using jQTouch, and I'm trying to stay fullscreen at all times; that is, horizontal scrolling is bad. Whenever I click an <input> element, the page scrolls right, showing a black border on the right of the screen and de-centering everything. The inputs are offset from the left of the screen, and they begin somewhere toward the middle of the page.

如何防止此焦点滚动?

推荐答案

我刚在这篇文章中找到了解决这个问题的方法停止页面从焦点滚动

I just found the solution to this problem in this post Stop page scrolling from focus

只需添加 onFocus =window.scrollTo(0 ,0);到您的输入字段,您就完成了!
(尝试用< textarea> < input type =text/> 在iPad上,但我很确定它也适用于iPhone。)

Just add onFocus="window.scrollTo(0, 0);" to your input field and you're done! (Tried it with <textarea> and <input type="text" /> on the iPad, but I'm pretty sure it'll work on the iPhone too.)

我担心滚动会像闪烁一样可见,但是幸运的是,情况并非如此!

I was afraid the scrolling would be visible as a flicker or something, but fortunately that is not the case!

这篇关于防止&lt;输入&gt;在iPhone上滚动屏幕的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆