在 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;
}
完。