2011-11-28 91 views
2

我创建了一个带有一些样式的<div>。其中一些是:iframe与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.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; 

但是,当我告诉这两个要素中,比<div>更大。它的宽度和高度与<div>不一样。这是如何造成的,我该如何解决这个问题?

+1

难道是填充/边框?你有没有尝试将它们设置为0? – Tom

+0

是的,它不起作用 –

+1

使用浏览器的开发者工具来查看它们被渲染的尺寸 –

回答

0

您是否尝试将iframe的宽度和高度设置为100%?

+0

是的......没有任何东西 –

+0

你有没有尝试过在div上使用100%宽度和高度以及iframe? –

+0

是的,但它不工作... :(请帮助我:( –