首页 > web前端 > css教程 > 正文

为什么 Internet Explorer 中 Iframe 中的 PDF 的 z-index 失败?

Linda Hamilton
发布: 2024-10-26 10:24:30
原创
713 人浏览过

Why Does z-index Fail for PDFs in Iframes in Internet Explorer?

z-index 在 Internet Explorer 中无法读取 iframe 中的 PDF

问题:

z-index 不起作用预期 iframe 在 Internet Explorer 8 中显示 PDF; iframe 出现在任何重叠元素之上。

说明:

解决方案:

要解决此问题,请插入另一个所需页面内容和 PDF iframe 之间的 iframe:

代码:

HTML:

<code class="html"><div id="outer">
    <div id="inner">my text that should be on top</div>
    <iframe class="cover" src="about:blank"></iframe>
</div>

<iframe id="pdf" src="http://legallo1.free.fr/french/CV_JLG.pdf" width="200" height="200"></iframe></code>
登录后复制

CSS:

<code class="css">#outer {
    position: relative;
    left: 150px;
    top: 20px;
    width: 100px;
    z-index: 2;
}

#inner {
    background: red;
}

.cover {
    border: none;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    z-index: -1;
}

#pdf {
    position: relative;
    z-index: 1;
}</code>
登录后复制

此附加 iframe 充当透明覆盖层,防止 PDF iframe 与其他页面元素重叠。

支持:

此解决方案已经过测试,可在 Internet Explorer 7-9 中运行。为了与其他浏览器兼容,请考虑使用 JavaScript 添加 iframe 或将其包装在仅 IE 的条件注释中:

<code class="html"><!--[if IE]><iframe class="cover" src="about:blank"></iframe><![endif]--></code>
登录后复制

以上是为什么 Internet Explorer 中 Iframe 中的 PDF 的 z-index 失败?的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!