【发布时间】:2014-11-21 11:08:20
【问题描述】:
我正在通过 JQM 创建一个站点/html5 应用程序。
每个页面都有一个固定的页眉和页脚,中心内容是可滚动的。在一个页面上,我有一个 iframe,它基于通过本地存储传递的外部站点的 url 动态填充。
目前 iframe 似乎有一些任意高度,远小于固定页眉和页脚之间的固定差异。
我需要 iframe 来填充页眉和页脚之间的空白,以便中间部分(主要)仅填充 iframe。我需要这个完美契合,这样当外部链接页面大于页眉和页脚之间的高度时(例如在移动设备上查看时),我不会在滚动中滚动。
我的 html 看起来像这样:
<body>
<div data-role="page" id="step3" class="mainpage" data-theme="a">
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<a href="#left-panel" data-role="button" data-icon="bars" data-prefetch data-dom-cache="true" data-tap-toggle="false">Menu</a>
<h1>Title</h1>
<a data-icon="back" data-rel="back" title="Go back">Back</a>
</div><!-- /header -->
<div role="main" class="ui-content step3" width="100%" height="100%" >
<div id="iframe" width="100%" height="100%" style="padding:0px;margin:0px;height:100%"></div>
</div><!-- /content -->
<div id="footing" data-role="footer" data-position="fixed" data-tap-toggle="false">
<div id="ad"> </div>
</div>
<script>
document.getElementById("iframe").innerHTML="<iframe src='" + localStorage.ExternalListing + "' width=\"100%\" height=\"100%\" style=\"padding:0px\;margin:0px\;min-height:500px\;height:100%\;\"></iframe>";
</script>
<style>
.ui-content.step3 {
padding: 0;
height:100%;
}</style>
</div><!-- /page -->
</body>
如您所见,我已尝试将“高度:100%”添加到相关部分,并在 iframe 中添加了最小高度(纯粹用于测试目的)。不幸的是,我不能为此使用固定高度,因为移动设备的屏幕尺寸和分辨率有很多变化。
有什么想法可以让 iframe 100% 填充页眉和页脚之间的空白吗?
【问题讨论】:
标签: css jquery-mobile cordova iframe phonegap-build