【发布时间】:2012-05-29 19:19:10
【问题描述】:
我发现了许多相关问题,但没有一个答案可以解释如何在 iOS 4 中使用两指方法滚动iframe。
通过设置width 和height 属性并设置overflow: scroll;,我可以用两根手指滚动div。这是一个更完整的例子:
<div style='width: 280px; height: 200px; overflow: scroll; -webkit-overflow-scrolling: touch;'>
Just imagine a bunch of content is in here, spanning well over 200px
worth of height. You can scroll this just fine in iOS 4 by using 2
fingers, or in iOS 5 by swiping 1 finger thanks to
"-webkit-overflow-scrolling: touch;".
</div>
在运行 iOS 4.3 的 iPad 1 上,这种方法不适用于 iframes。这是一个在 iOS 4 中不会用任何手指组合滚动的完整示例(当然,-webkit-overflow-scrolling 允许它在 iOS5 上工作):
<html>
<head>
<style type="text/css">
#scroller {
width: 280px;
height: 200px;
overflow: scroll;
-webkit-overflow-scrolling: touch;
}
#scroller iframe {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="scroller">
<iframe src="content.html">content.html is a big list of nonsense.</iframe>
</div>
</body>
</html>
我必须补充,如果我将iframe 的width 和height 设置为实际像素值,我可以 让两根手指滚动工作,像height: 1000px;,但我永远不会知道 iframe 的内容会有多高。所以,也许真正的问题是如何让 iOS 4 中的移动 Safari 相信 div 内部的 iframe 确实大于 280x200 像素?
【问题讨论】:
-
您可以在这里尝试解决方案stackoverflow.com/a/18699378/768685