iframe在ios上不能滾動問題解決


這篇文章一樣,用到了-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 參考文檔中有所提及。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM