简体   繁体   English

与div具有相同宽度和高度的iframe

[英]Iframe with same width and height as div

I've created a <div> with some styles. 我创建了具有某些样式的<div> Some of them are: 他们之中有一些是:

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

Then, I've created an <iframe> : 然后,我创建了一个<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;

But, when I show both elements, the <iframe> is bigger than the <div> . 但是,当我同时显示两个元素时, <iframe>大于<div> It has not the same width and height as the <div> . 它的宽度和高度与<div> How is this caused and how can I solve it? 这是怎么引起的,我该如何解决?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM