今天在解决公司平台网页在手机端访问兼容性问题时,遇到index页面通过iframe嵌入右边内容页面在anroid显示正常(主要为:页面内容超过iframe高度、宽度,可以正常显示滚动条,也可以滑动显示),但是在iphone自带的浏览器或者在iphone下载其他浏览器访问,iframe内容均无法全部显示,主要表现为:
1、iframe只显示了嵌入内容的部分,无法显示全部,感觉内容被截掉了
2、iframe展示滚动条,实现滑动访问全部内容
后经过查找相关资料,通过以下方式解决:
参考:https://www.jianshu.com/p/bd9fbf5a14f0dai
css及html设置
<!--设置外部div样式,尽量不要写在页面div style中,有可能不起作用-->
.show_iframe{
-webkit-overflow-scrolling: touch;
overflow-y:
scroll;position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.show_iframe iframe {position: absolute;bottom: 0;height: 100%;width: 100%}
<!--在iframe外包一个div-->
<div class="show_iframe">
<div style="display:none" class="loading"></div>
<iframe scrolling="yes" frameborder="0" wicket:id="mainPage"></iframe>
</div>
以上代码亲测可用,希望我走过的坑,大家都能在看过我的文章后跳过去,那我也就欣慰了,哈哈