修复了移动应用程序iframe中的底部页脚

Fixed bottom footer inside iframe on mobile app

本文关键字:底部 iframe 移动 应用程序      更新时间:2023-09-26

我需要在iframe中固定底部页脚。这里我使用全高宽iframe。所以现在我在这个文件里面有一个页面iframe.html,我在这里使用index.html文件,我有一个固定的页脚。它工作良好的网络和安卓浏览器,但它不适用于iOS safari浏览器。

为此,我在页脚中使用position: fixed属性。

iframe.html文件

<iframe src="index.html" id="iframe"></iframe>

iframe.html css文件

iframe {
    position:absolute;
    top:0;
    left:0;
    width:100%;
    overflow: hidden;
    -webkit-overflow-scrolling:touch;
}

index.html文件

HTML代码

<script>
    for(var i = 0; i < 100; i++)
        document.write("<div> test :: " , i , "</div>");
</script>
<footer>
    <p>footer</p>
</footer>

CSS代码

footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padiing: 0.5em;
}

问题出在position:fixed上,与桌面相比,它在移动浏览器中的工作方式有所不同。

我建议你通过以下链接

第五个位置值