简体   繁体   English

根据 Iframe 宽度/高度调整 Iframe 内容

[英]Resize Iframe content according to Iframe Width/Height

How do I resize a Iframe's contents to fill the width/height of the Iframe?如何调整 iframe 内容的大小以填充 Iframe 的宽度/高度?

I've changed the width and height of the Iframe to make it bigger, however the content is not scaling with it which leaves a bunch of whitespace (It's like the content is absolutely positioned at the top left of the Iframe).我已经更改了 Iframe 的宽度和高度以使其更大,但是内容不会随其缩放,从而留下一堆空白(就像内容绝对位于 iframe 的左上角一样)。

<iframe width="500px" height="300px" frameborder="0" 
  scrolling="no" src="someContent">
</iframe>

Why doesn't the Iframe's content scale when you set an Iframe's width/height?为什么设置 iframe 的宽度/高度时 iframe 的内容不缩放?

If you don't have control over the content of the iframe (ie you cannot edit the source), you could try to scale the iframe, like this:如果您无法控制 iframe 的内容(即您无法编辑源代码),您可以尝试缩放 iframe,如下所示:

<iframe width="500px" height="300px" frameborder="0" 
  scrolling="no" src="someContent" 
  style="-webkit-transform:scale(0.5);-moz-transform-scale(0.5);">
</iframe>

You should experiment with height , width and the scale value to achieve your desired result.您应该尝试使用heightwidth和 scale 值来达到您想要的结果。

Also see: Resize external website content to fit iFrame width另请参阅: 调整外部网站内容大小以适合 iFrame 宽度

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

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