单指滚动iPhone Mobile Safari中的内容(div / iframes)

时间:2011-05-07 14:28:59

标签: iphone mobile safari css-position css

Sub:iPhone移动野生动物园网络应用程序

即使用户滚动,我也需要保持网页的某些部分可见。 CSS属性position:fixed不能按预期工作。使用overflow:auto属性或需要双指滚动,这不是我想要的。

有没有办法使用javascript或iphone safari Touch API(touchMove事件)在内部'div'或'iframes'内容上提供单指滚动?

3 个答案:

答案 0 :(得分:31)

在CSS(适用于iOS 5)中:

-webkit-overflow-scrolling: touch;

答案 1 :(得分:1)

本地使用div或iframe无法实现,因此必须通过javascript侦听触摸事件来解决。我正在为一个项目研究同样的问题,目前我发现了一些解决这个问题的javascript库。

我现在正在调查这个,但我还没有承诺。

http://cubiq.org/iscroll-4

Three20成名的Joe Hewitt最近也开始开发解决方案,但是他在开发过程中很早,而另一个已经存在了几年。

http://joehewitt.github.com/scrollability/

答案 2 :(得分:0)

你可以只用一根手指,但你必须提供内部DIV的style.height

<div id="container-div" style="overflow:hidden">
   <div id="inner-div" style="overflow-y:auto; height:1024px"> 
   <!-- IMPORTANT!! you must specify the height of the inner div to make it scrollable -->