ios app混合开发中iframe的scroll滚动失效解决方法

xiaoxiao2021-02-28  59

失效原因

当iframe的内容超出了iframe设定的高度时,在ipad、iphone等设备上,iframe内部html的滚动条不出现,超出iframe高度的会部分被截掉(类似overflow:hidden的效果)。

解决方法一

使用iframe或者其他html元素时,使用一个元素(如DIV)来包装他们:

<div class="scroll-wrapper"> <iframe src=""></iframe> </div> <style> .scroll-wrapper { -webkit-overflow-scrolling: touch;/* touch或auto */ overflow-y: scroll; } .scroll-wrapper iframe { width:100%; height:100%; /* 你自己指定的样式 */ } </style>

方法二

不使用iframe,直接使用网页跳转

function open(url){ window.open(url,'_blank','location=no'); }
转载请注明原文地址: https://www.6miu.com/read-85800.html

最新回复(0)