调整外部网站内容的大小以适合 iFrame 宽度 [英] Resize external website content to fit iFrame width

查看:45
本文介绍了调整外部网站内容的大小以适合 iFrame 宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 2 个 iFrame 的网页.它们都具有固定的宽度和高度.我正在其中加载外部网站.如何调整这些外部网站的宽度以适应 iFrame(就像移动浏览器通过更改视口所做的那样)?

I have a webpage with 2 iFrames in it. Both of them are with fixed width and height. I am loading external websites inside them. How can I resize those external websites width to fit with the iFrame (like mobile browsers does by changing viewport)?

推荐答案

您可以做的是为 iframe 设置特定的宽度和高度(例如,这些可能等于您的窗口尺寸),然后对其应用缩放变换.缩放值将是您的窗口宽度与您要设置为 iframe 的尺寸之间的比率.

What you can do is set specific width and height to your iframe (for example these could be equal to your window dimensions) and then applying a scale transformation to it. The scale value will be the ratio between your window width and the dimension you wanted to set to your iframe.

例如

<iframe width="1024" height="768" src="http://www.bbc.com" style="-webkit-transform:scale(0.5);-moz-transform-scale(0.5);"></iframe>

这篇关于调整外部网站内容的大小以适合 iFrame 宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆