当我使用下面的代码来创建一个iframe:

<iframe src="mypage.html" style="border: 0; width: 100%; height: 100%">Your browser doesn't support iFrames.</iframe>

iframe并没有一直延伸——一个10px的白色“边框”围绕着iframe。我怎么解决这个问题呢?

这是这个问题的一个图像:


当前回答

将这个添加到你的iframe中可能会解决这个问题:

frameborder="0"  seamless="seamless"

希望能有所帮助。

其他回答

将这个添加到你的iframe中可能会解决这个问题:

frameborder="0"  seamless="seamless"

希望能有所帮助。

尝试添加以下属性:

scrolling="no"

要覆盖整个视口,你可以使用:

<iframe src="mypage.html" style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;">
    Your browser doesn't support iframes
</iframe>

并且确保将框架页面的边距设置为0,例如body {margin: 0;}。-实际上,这个解决方案不需要这样做。

我成功地使用了这个,有一个额外的显示:none和JS显示它时,用户单击适当的控件。

注意:要填充父视图区域而不是整个视口,将position:fixed改为position:absolute,并确保父视图的位置不是静态的。

正文在大多数浏览器中都有默认的边距。试一试:

body {
    margin: 0;
}

在带有iframe的页面中。

你可以使用这段代码:

  <iframe src="http://example.com" frameborder="0" style="overflow:hidden;overflow-x:hidden;overflow-y:hidden;height:100%;width:100%;position:absolute;top:0%;left:0px;right:0px;bottom:0px" height="100%" width="100%"></iframe>