iPad Scrolling to Top of iframe

这一生的挚爱 提交于 2019-12-07 02:53:50

问题


I did my best to recreate this in something accessible. I've got an ipad mini running ios7 and am using something similar to this:

<div id="holder">
    <iframe height="100%" width="100%" src="http://www.cnn.com" id="iframe"></iframe>
</div>

#holder {
    height:500px;
    width:100%;
    overflow:scroll;
    -webkit-overflow-scrolling: touch;
}

See fiddle: http://jsfiddle.net/khJgY/4/

Now the issue is, scrolling in the iframe works fine. But if you change focus (say to one of the other HTML/CSS/JS edit boxes) the iframe scrolls back to the top left and I have no idea why.

Any help would be appreciated.


回答1:


The following CSS fixed it for me. (source)

On the inner iframe:

html, body
{
    width: 100%; height: 100%; overflow: auto; -webkit-overflow-scrolling: touch;
}



回答2:


the following css fixed it for me:

html, body
{
    height: 100%;
    padding-bottom: 1px;
}



回答3:


I just ran into this problem myself. I found out that is a bug where certain CSS makes the browser jump to the top of the page, but only in certain situations, like in forms and iframes. For me, I found out that applying a box-shadow when a button was active made this happen. To fix it, I just made the effect not trigger on smaller screens by setting box-shadow: none;.



来源:https://stackoverflow.com/questions/21342057/ipad-scrolling-to-top-of-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!