完全使用 iframe 嵌入页面,没有边框,在边框曾经的位置没有空格

Embed a page completely using iframe, no border, no whitespace where the border once was

本文关键字:边框 曾经 空格 位置 iframe      更新时间:2023-09-26

>我有以下代码

<html>
<body>
<iframe src="http://anothersite.com" style="width:100%; height:100%;  overflow-y: scroll; overflow-x: hidden;"   marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" seamless="seamless" ></iframe>
</body>
</html>

它有一个 iframe,我想在其中显示另一个网站,就像它是网站上的一个页面一样。但是,当删除边框并且滚动条仍然存在时,仍然存在一些空白,但它只是仍然存在。我希望它不可见但仍然可以滚动,边框空间消失了。请提供任何帮助,我们将不胜感激。我还没有找到在我正在使用的浏览器 (Chrome) 上对我有用的直接答案。谢谢。

页面始终具有默认边距/填充,并且浏览器和浏览器使用的模式有所不同。

添加文档类型,以便页面不会以 quirks 模式呈现(因为这会降低其可预测性)。添加一个样式表,用于删除 body 元素的边距和填充。

<!DOCTYPE html>
<html>
<head>
<title>Page name</title>
<style>
html { height: 100%; }
body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
</style>
</head>
<body>
<iframe src="http://anothersite.com" style="width:100%; height:100%;  overflow-y: scroll; overflow-x: hidden;"   marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" seamless="seamless" ></iframe>
</body>
</html>