PhoneGap + JQM Android 滚动问题
我是 StackOverflow 的新手,但我在谷歌搜索时读了很多帖子;-)
我正在使用 PhoneGap + jQuery Mobile 组合开发一个 webApp,但我在 Android 上遇到滚动问题。我的页面如下所示:
<div data-role="page" id="categories">
<div data-role="header">...</div>
<div data-role="content" style="padding:0 15px;">
<div id="categories_canvas" style="overflow-y:scroll;">...</div>
</div>
<div data-role="footer">...</div>
</div>
我的 JS 上有:
var height_canvas = $(window).height() - $("div.ui-footer").outerHeight() - $("div.ui-header").outerHeight()
$("#categories_canvas").height(height_canvas);
设置高度有效,但 overflow-y:scroll
不适用于我的 HTC Desire (Android 2.3.3) 和 HTC Sensation (Android 3.4)。 ?.? - 不太记得了)但在我的 Samsung Galaxy Nexus (Android 4.0.2) 上运行良好。
我不知道为什么,我正在寻找解决方案...我做了一些测试,发现如果不使用溢出,页面会滚动,但我的页脚没有固定在屏幕底部,我会使用滚动内容固定页眉/内容/页脚。
编辑:好的,我在互联网上阅读了很多页面,似乎不支持溢出(以及许多其他......)。因此,我决定将菜单链接放在标题上,与标题标题内联(就像 iOS 上的“后退”按钮)。我只有三页,减去实际的我有两个链接,所以将它们放在标题上对我来说是一种选择。真可惜 !但它有效,这是必不可少的;-)
I'm new on StackOverflow, but I read a lot of posts when googling ;-)
I'm developping a webApp using PhoneGap + jQuery Mobile combo and I have a problem with scroll on Android. My page looks like this :
<div data-role="page" id="categories">
<div data-role="header">...</div>
<div data-role="content" style="padding:0 15px;">
<div id="categories_canvas" style="overflow-y:scroll;">...</div>
</div>
<div data-role="footer">...</div>
</div>
I have on my JS :
var height_canvas = $(window).height() - $("div.ui-footer").outerHeight() - $("div.ui-header").outerHeight()
$("#categories_canvas").height(height_canvas);
Setting height works, but the overflow-y:scroll
doesn't on my HTC Desire (Android 2.3.3) and HTC Sensation (Android 3.?.? - don't remember exactly) but works great on my Samsung Galaxy Nexus (Android 4.0.2).
I don't know why and I'm searching for a solution... I made some tests and I discovered that if I don't use the overflow, the page scrolls but my footer isn't fixed at the bottom of the screen, and I would a fixed header/content/footer with scrolled content.
EDIT : Okay, I have read a lot of pages on internet, and it seems that the overflow is not supported as I would (and many others...). So I decided to put my menu links on the header, inline with the header title (like "Back" button on iOS). I have only three pages, minus actual I have two links, so putting them on the header is for me an alternative. What a pity ! But it works and this is the essential ;-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的 HTC Desire 也遇到了同样的问题。试试这个:
I had the same problem on my HTC Desire. Try this:
如果您确实想要滚动,请使用 iscroll 4 插件。它适用于许多操作系统,它加快了开发速度并允许您拥有更多的控制权。 http://cubiq.org/iscroll-4
Use the iscroll 4 plug in if you really want the scroll. It works on many OS, it speeds developement and allows you to have a lot of controll. http://cubiq.org/iscroll-4