同這篇文章一樣,用到了-webkit-overflow-scrolling: touch;屬性。主要解決方案是在iframe外層添加一個div,然后設置-webkit-overflow-scrolling屬性。
例如:
<div class="content-iframe-wrapper">
<iframe frameborder="0" class="content-iframe" src=""></iframe>
</div>
.content-iframe-wrapper {
-webkit-overflow-scrolling: touch;
overflow-y: auto;
width: 100%;
height: calc(100vh - 60px);
}
.content-iframe-wrapper .content-iframe {
width: 100%;
height: 100%;
}
MDN文檔:https://developer.mozilla.org/zh-CN/docs/Web/CSS/-webkit-overflow-scrolling
該特性是非標准的,尚未有相關規范。另在Apple提供的Safari CSS 參考文檔中有所提及。