[記錄]讓 IOS 支持 iframe 滾動(dòng)

在 IOS 上使用 iframe 的時(shí)候,發(fā)現(xiàn)超出的內(nèi)容無法滾動(dòng)了,在安卓上沒有發(fā)現(xiàn)這樣的問題。使用 -webkit-overflow-scrolling 屬性可以解決這個(gè)問題。
HTML 代碼:

<!-- 新聞?lì)A(yù)覽 -->
<section class="view-news" id="view-news">
    <div class="loading" id="loading"></div>
    <div class="news-box">
        <div class="close"></div>
        <div class="content">
            <iframe id="news_iframe" name="news_iframe"></iframe>
        </div>
    </div>
</section>

要讓 iframe 內(nèi)容超出后能夠在 IOS 下繼續(xù)滾動(dòng),需要在最外層的 section 標(biāo)簽應(yīng)用如下樣式:

/* 新聞?lì)A(yù)覽 */
section.view-news{
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 99999;
    display: none;
    text-align: center;
    overflow-y: auto;   
    overflow-x: hidden;
    /** 新增 -webkit-overflow-scrolling 屬性設(shè)置 **/
    -webkit-overflow-scrolling: touch;  
}

完。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容