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

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

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


当前回答

如果要放置iframe的页面的doctype是HTML5,则可以使用无缝属性,如下所示:

<iframe src="..." seamless="seamless"></iframe>

无缝属性上的Mozilla文档

其他回答

您可以在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中使用。

在样式表中添加

{
  padding:0px;
  margin:0px;
  border: 0px

}

这也是一个可行的选择。

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

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

对于特定于浏览器的问题,还可以根据Dreamweaver添加frameborder=“0”hspace=“0“vspace=“1”marginheight=“2”marginwidth=“0”:

<iframe src="test.html" name="banner" width="300" marginwidth="0" height="300" marginheight="0" align="top" scrolling="No" frameborder="0" hspace="0" vspace="0">Browser not compatible. </iframe>