Phonegap垂直滚动
我正在为ios构建一个phonegap应用程序,并有垂直滚动问题。即使没有任何内容,在web视图中似乎也会滚动几个像素,这会影响我绝对定位的导航栏和标签栏,它们都是以html格式构建的Phonegap垂直滚动
以下是我拥有的html页面 - 没有内容图中显示的滚动量:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<title>My App</title>
</head>
<body>
<script src="scripts/vendor/cordova-2.4.0.js"></script>
</body>
</html>
scroll screenshot http://img20.imageshack.us/img20/5140/screenshot20130225at212.png
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
<meta name="viewport" content="user-scalable=no, initial-scale=1, minimum-scale=1, width=device-width" />
而且在config.xml中:
<preference name="DisallowOverscroll" value="true" />
以上是设置我发现在iOS滚动操作的最佳开局。然后,只需将“overflow:auto”添加到您需要滚动的任何元素即可。使用推翻或iscroll来帮助支持iOS < 5,android < 3等等。
这可能帮助:
body {
height: 100%;
overflow: hidden;
}
您好我已经试过了,好像即使是新安装的PhoneGap的有这个问题。 – 2013-02-26 07:39:30
同样的问题给我... – jocull 2013-06-19 21:43:42
这解决它对我来说(至少在iOS上 - 可能在其他平台上具有其他兼容性的东西)
尝试从顶部的元中删除width=device-width, height=device-height
。
这是一个设备不考虑顶部状态栏的问题,据我所知。
啊哈!这次真是万分感谢。试图找到它失去了一个晚上。佩斯克设备高度。为我粘贴建议的元标记而无需正确研究它的作用。 – Ade 2013-08-06 20:28:12
以上都不是固定我的问题,但下面的链接。就我而言,内容之下的差距超出了无法解释的范围,这种差距导致了滚动条。
这里是链接: https://github.com/phonegap/phonegap/wiki/Prevent-Scrolling
试着隐藏到系统托盘,它的伎俩我。
在MainPage.xaml上,将“IsVisible”设置为false。
shell:SystemTray.IsVisible="False" d:DesignHeight="768" d:DesignWidth="480"
对于最新的答案(截至2016年),这个解决方案对我来说是Cordova iOS中最有效的(平滑滚动)。
.element {
overflow-y: scroll; /* has to be scroll, not auto */
-webkit-overflow-scrolling: touch;
}
来源: https://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/
非常好!这似乎解决了这个小问题。我几乎准备好完全放弃电话 - 几周来一直试图为此找到解决办法 – 2013-06-22 10:06:20