【发布时间】:2017-11-09 10:44:48
【问题描述】:
我在移动 iOS Safari 中遇到问题,在 iFrame 本身内部拖动时,无法在包含 iFrame 的 div 中滚动:
#outside{
height: 400px;
width: 200px;
background: blue;
overflow: scroll;
}
.space{
height: 200px;
width: 200px;
background: red;
}
iframe{
height: 1000px;
width: 200px;
background-color: green;
}
The green section is the iFrame.... Scrolling on the green section in iOS mobile is the issue
<div id="outside">
<div class="space"></div>
<iframe>
</iframe>
<div class="space"></div>
</div>
所以,在 iFrame 上拖动时,由于它没有滚动,它应该滚动父级,而是滚动整个页面。
此错误的任何已知解决方法?它已经在 Android 上运行。
【问题讨论】:
-
小提琴链接:jsfiddle.net/hpo2dg6d/1
-
将
pointer-events: none;添加到 iFrame 元素可以解决问题,但这不是一个选项,因为 iFrame 包含需要正常工作的链接。 :P -
这是 Chris Coyier 最近发表的一篇我觉得很有趣的文章:blog.codepen.io/2017/12/01/stupid-iframes-stupid-ios
标签: html ios css iframe mobile-safari