问题描述
我有一个包含2个iFrames的网页。两者都有固定的宽度和高度。我在里面加载外部网站。如何调整这些外部网站的宽度以适应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宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!