iframe的宽度和高度与div相同

时间:2011-11-28 11:00:12

标签: javascript html css

我创建了一个带有一些样式的<div>。其中一些是:

contenedor.style.position = "absolute";
contenedor.style.top = "60px";
contenedor.style.left = "610px";
contenedor.style.width = "auto"; // Auto-adjust to the content
contenedor.style.height = "auto";// Auto-adjust to the content

然后,我创建了一个<iframe>

iframe.setAttribute("scrolling", "no");
iframe.style.width = contenedor.style.width;
iframe.style.height = contenedor.style.height;
iframe.style.top = contenedor.style.top;
iframe.style.left = contenedor.style.left;

但是,当我显示两个元素时,<iframe>大于<div>。它与<div>的宽度和高度不同。这是怎么造成的,我该如何解决?

1 个答案:

答案 0 :(得分:0)

您是否尝试过制作iframe的宽度和高度100%?