最近工作中遇到将之前网页以iframe的形式插入到现有网页中业务需要,完成后在chrome浏览器上测试时并没有出现问题,然后交给测试同学时,出现问题了,iframe自动变宽了,在IOS手机上出现滚动条。解决步骤如下,亲测有效。
第一步:定义 iframe 中的scrolling属性为no,设置iframe中不显示滚动条。
<iframe scrolling="no" ></iframe>
第二步:设置iframe的样式为如下所示
iframe{
overflow: scroll;
-webkit-overflow-scrolling: touch;
min-width: 100%;
*width:100%;
width:1px;
}