Does anyone know of a way to auto resize an iframe when you make your browser smaller??
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can attach a handler to the window.onresize
event, and then resize your IFRAME appropriately.
I prefer jQuery:
$(window).resize(function() {
$('IFRAME').width($(window).width());
});
回答2:
One option is to specify the <iframe>
size in percent.
回答3:
Haven't tried it but I guess you could use a percentage width instead of a fixed width. In that case you should probably add a minimum width and height as well, to avoid that it is getting too small:
iframe
{
width: 50%;
height: 50%;
min-width: 300px;
min-height: 300px;
}
回答4:
You could as well use this.
Basically it makes use of callResize() in Child page and resizeIframe() in Parent page.
回答5:
You can also do this without JavaScript if you'd like using CSS Media Queries. See this example here:
http://ie.microsoft.com/testdrive/HTML5/CSS3MediaQueries/Default.html
They are often used for "responsive design".