Html 使 iframe 透明

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14065959/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 04:35:56  来源:igfitidea点击:

making the iframe transparent

htmlcss

提问by user1929236

Possible Duplicate:
How to create transparent frameset?

可能的重复:
如何创建透明框架集?

I am trying to make the iframe trasparent but it showing white color in my firefox browser. I have used the following code for the iframe

我正在尝试使 iframe 透明,但它在我的 Firefox 浏览器中显示为白色。我已将以下代码用于 iframe

<iframe id="frontimg" src="slider/slide.html" width="950" height="370" border="0" scrolling="no" allowTransparency="true"></iframe>

And in my desired html file i have put this code in head tag for styling:

在我想要的 html 文件中,我将此代码放在 head 标记中以进行样式设置:

<style type="text/css">
    html,
    body {
        background-color: transparent;
    }
</style>

回答by wildhaber

In Firefox you need to start with none in the background:

在 Firefox 中,您需要在后台从 none 开始:

<style type="text/css">
    body {
        background: none transparent;
    }
</style>

回答by pocesar

You can't style iframes from the outside. Unless the content inside the iframe have no background color, you are out of luck. If it's inside your own domain, you may set the background transparent if it's being called from inside an iframe (in your iframe head):

您不能从外部设置 iframe 的样式。除非 iframe 内的内容没有背景颜色,否则你就不走运了。如果它在您自己的域内,并且从 iframe 内部(在您的 iframe 头中)调用它,则可以将背景设置为透明:

<script type="text/javascript">
 if (window!= window.top) { // inside iframe
   document.body.style.backgroundColor = 'transparent';
   // or document.body.style.background = 'none';
 }
</script>

回答by Muhammad Talha Akbar

Document is By Default White. Setting Body To Transparent and IFRAME to transparent will still show you white color. You can't make the document as a whole transparent! You can Make Elements On a Document to be Transparent.

文档默认为白色。将 Body 设置为 Transparent 并将 IFRAME 设置为透明仍然会显示白色。你不能让文档整体透明!您可以使文档上的元素透明。