如何从嵌入在web应用程序中的iframe中删除边框?iframe的一个示例是:

<iframe src="myURL" width="300" height="300">Browser not compatible.</iframe>

我希望从页面上的内容到iframe内容的转换是无缝的,假设背景颜色是一致的。目标浏览器仅为IE6,不幸的是,针对其他浏览器的解决方案将无济于事。


当前回答

要删除边框,可以将CSS边框属性设置为none。

<iframe src="myURL" width="300" height="300" style="border: none">Browser not compatible.</iframe>

其他回答

我尝试了上面的所有方法,如果这些方法对你不起作用,那么试试下面的CSS解决了我的问题。它只是告诉浏览器不要添加任何填充或边距。

* {
  padding:0px;
  margin:0px;
 }

在尝试删除IE7中的边框后,我发现frameBorder属性区分大小写。

必须将frameBorder属性设置为大写B。

<iframe frameBorder="0"></iframe>
<iframe src="URL" frameborder="0" width="100%" height="200">
<p>Your browser does not support iframes.</p>
</iframe>

<iframe frameborder="1|0">

(OR)

<iframe src="URL" width="100%" height="300" style="border: none">Your browser 
does not support iframes.</iframe>

The <iframe> frameborder attribute is not supported in HTML5. Use CSS 
instead.

您可以在iframe代码中使用style=“border:0;”。这是HTML5中删除边框的推荐方法。

查看我的html5 iframe生成器工具,无需编辑代码即可自定义iframe。

<iframe src="mywebsite" frameborder="0" style="border: 0px solid white;">HTML iFrame is not compatible with your browser</iframe>

这段代码应该可以在HTML4和HTML5中使用。