<div class="scroll-wrapper">
<iframe src=""></iframe>
</div>
首先給這個wrapper設個樣式:
.scroll-wrapper {
-webkit-overflow-scrolling: touch;
overflow-y: scroll;
/* 提示: 請在此處加上需要設置的大小(dimensions)或位置(positioning)信息! */
}
然后把iframe撐滿:
.scroll-wrapper iframe {
height: 100%;
width: 100%;
}
這樣在js動態生成iframe的時候,就不用再做對body高度的特判了。
原文來自這里