Kar*_*lth 88
iOS 5添加了以下样式,可以添加到父div,以便滚动工作.
-webkit-overflow-scrolling:touch
Dip*_*nan 24
-webkit-overflow-scrolling:touch 正如答案中提到的那样可能是解决方案.
<div style="overflow:scroll !important; -webkit-overflow-scrolling:touch !important;">
<iframe src="YOUR_PAGE_URL" width="600" height="400"></iframe>
</div>
Run Code Online (Sandbox Code Playgroud)
但如果您无法在iframe内上下滚动,如下图所示,

你可以尝试用2个手指沿对角线滚动,

这实际上适用于我的情况,所以如果您还没有找到解决方案,请分享它.
iframes似乎没有正确显示和滚动.您可以使用object标签替换iframe,内容可以用2个手指滚动.这是一个简单的例子:
<html>
<head>
<meta name="viewport" content="minimum-scale=1.0; maximum-scale=1.0; user-scalable=false; initial-scale=1.0;"/>
</head>
<body>
<div>HEADER - use 2 fingers to scroll contents:</div>
<div id="scrollee" style="height:75%;" >
<object id="object" height="90%" width="100%" type="text/html" data="http://en.wikipedia.org/"></object>
</div>
<div>FOOTER</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这不是我的答案,但我只是从https://gist.github.com/anonymous/2388015复制它只是因为答案很棒并完全解决了问题.信用完全归于匿名作者.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
if (/iPhone|iPod|iPad/.test(navigator.userAgent))
$('iframe').wrap(function(){
var $this = $(this);
return $('<div />').css({
width: $this.attr('width'),
height: $this.attr('height'),
overflow: 'auto',
'-webkit-overflow-scrolling': 'touch'
});
});
})
</script>
Run Code Online (Sandbox Code Playgroud)
正如其他帖子中提到的,溢出的css值的组合:auto; &-webkit-overflow-scrolling:touch;
当应用于有问题的iframe及其父div时,它可以正常工作
由于双滚动条在非触摸浏览器上的不幸副作用.
我使用的解决方案是通过javascript/jquery添加这些css值.这让我可以为所有浏览器使用基本CSS
if (isSafariBrowser()){
$('#parentDivID').css('overflow', 'auto');
$('#parentDivID').css('-webkit-overflow-scrolling', 'touch');
$('#iframeID').css('overflow', 'auto');
$('#iframeID').css('-webkit-overflow-scrolling', 'touch');
}
Run Code Online (Sandbox Code Playgroud)
其中isSafariBrowser()被定义为foll ...
var is_chrome = navigator.userAgent.indexOf('Chrome') > -1;
var is_safari = navigator.userAgent.indexOf("Safari") > -1;
function isSafariBrowser(){
if (is_safari){
if (is_chrome) // Chrome seems to have both Chrome and Safari userAgents
return false;
else
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
这允许我的应用程序在iPad上工作注1)未在其他ios系统上测试过2)未在平板电脑上的Android浏览器上测试过,可能需要进行其他更改
(所以这个解决方案可能不完整)