我創建了一個帶有一些樣式的<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
是的,它不起作用 –
使用瀏覽器的開發者工具來查看它們被渲染的尺寸 –