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

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

问题描述

我的网页上有几个 元素.我正在使用 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.

如何防止在焦点上滚动?

How can I prevent this scrolling on focus?

推荐答案

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

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

只需将 onFocus="window.scrollTo(0, 0);" 添加到您的输入字段即可!(在 iPad 上用