Html 如何在不指定尺寸的情况下使 iframe 适合整个屏幕?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7439503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make an iframe fit the entire screen without specifying dimensions?
提问by deltanovember
If I don't specify any dimensions, the iframe appears tiny. If I do specify dimensions as follows then it does not properly scale for different screen resolutions
如果我没有指定任何尺寸,iframe 就会显得很小。如果我按如下方式指定尺寸,则它无法针对不同的屏幕分辨率正确缩放
<iframe name="report"style="height:1200px;width:800px;">
Is there a way to automatically allow the iframe to stretch to the entire screen?
有没有办法自动允许 iframe 拉伸到整个屏幕?
回答by checkenginelight
Use %
用 %
<iframe name="report" height="100%" width="100%"></iframe>
回答by alex
Assuming the iframe
has no small ancestor with position: relative
.
假设iframe
有不小的祖先与position: relative
。
<iframe name="report"style="position: absolute; top: 0; right: 0; bottom: 0: left: 0;">
You should also consider using an external stylesheet.
您还应该考虑使用外部样式表。
回答by Lalit Baghel
<div style="overflow: hidden;position: relative; height:200px;" >
<iframe class="" rel="nofollow" style="height: 800px; width:1400px; transform: scale(0.294167) !important; transform-origin: 0px 0px;" frameborder="0" scrolling="no"
src="your iframe link"></iframe></div>