我目前正在尝试让 iframe 适合我的屏幕尺寸,以及任何其他以不同分辨率使用它的用户,除非无论我尝试什么,最终都会导致 iframe 太小或高度太大导致双滚动条。 (iframe 和页面本身有滚动条)。
我的目标是让 iframe 仅适合页面宽度的 85%(这有效!),距离屏幕顶部 100 像素(也有效),然后让底部适合我的浏览器底部的边缘(这就是其中的位置)我被困住了...)
HTML
<div id="maindiv" class="maindiv">
<iframe id="theiframe" class="iframeautowidth" seamless src="http://whateverdomain.com></iframe>
</div>
CSS:
.maindiv {
width: 85%;
top: 100px;
}
.iframeautowidth {
left: 0px;
top: 0px;
bottom: 0px;
width: 85%;
height: 100%;
border: 0
overflow: hidden;
display: block;
margin: 0;
float: left;
}
如果有什么意义的话,我在我的页面上运行了最新的jquery,如果它有帮助的话。提前致谢!
Use the onload()
你的 iframe 的事件和onresize()
将 iframe 大小调整为所需大小的窗口事件。
这篇 Microsoft 支持文章 http://support.microsoft.com/kb/278469解释得很好。
仅供参考,在 JavaScript 中screen.width
& screen.height
将为您提供屏幕分辨率。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)