透明背景iframe仅在Firefox而不是Chrome或Safari工作
我试图在 iframe 上获得透明背景,但我只能在 Firefox 上使用它。我已经尝试了所有不同的方法让它工作,但这是我现在在 iframe 中的页面上使用的 css:
html, body {
background: linear-gradient(top, blue, transparent);
}
这是 Firefox 中的结果(以及所需的结果): | 这就是我进入 Safari 的 chrome: |
---|---|
![]() |
![]() |
我使用 JavaScript 添加的 iframe:
<iframe class='repoImg' allowtransparency='true' frameborder='0' src='objectpreview.html?objecturl="+ element +"' title='3D model of "+ element +"'>
有没有办法在所有浏览器上获得所需的结果?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iframes默认为透明
如果iframe自己设置了背景颜色,则它将使用其选择的任何颜色。但是,如果它没有设置背景颜色,则它是透明的,并显示到父母的页面。
由于您得到的结果不同,因此iframe中的某些内容正在制作白色。
iframes default to transparent
If the iframe is setting a background color on it's own then it will use whatever color it chose. But if it does not set a background color then it's transparent and shows through to the parent's page.
Since you're getting a different result, something in your iframe is making that white color.