我创建了一个带有一些样式的<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>
不一样。这是如何造成的,我该如何解决这个问题?
难道是填充/边框?你有没有尝试将它们设置为0? – Tom
是的,它不起作用 –
使用浏览器的开发者工具来查看它们被渲染的尺寸 –