【问题标题】:Scroll with iframe in phonegap iOS在 phonegap iOS 中使用 iframe 滚动
【发布时间】:2017-09-08 08:25:19
【问题描述】:

如果我的 PhoneGap 应用中有 iframe。框架的高度为 1000。 通过将其宽度调整为 50%,我可以通过触摸框架旁边空间上的父级来滚动。但是当我尝试通过触摸框架本身来滚动时,没有任何反应。

我查找了这个问题,并报告了一些问题,这些问题与包括 -webkit-overflow-scrolling 在内的解决方案一起出现:touch;但没有运气。

#content_wrap {
    display: inline-block;
    float:left;
    width:100%;
    overflow-x:hidden;
    position:relative;
    height:auto;
    z-index:300;
}


#content_wrap  .content_container {
    position:absolute;
    left:0px;
    display:inline-block;
    float:left;
    width:100%;
    padding:0;
    min-height:100%;
    height:auto;
    background-color:#FFF;
}

#tickets {
    display:inline-block;
    float:left;
    width:50%;
    margin:0px;
    height:auto;
}

#ticketFrame {
    height:1000px;
    display:inline-block;
    float:left;
    width:100%;
}

html:

<div id="content_wrap">
   <div class="content_container">
      <div id="tickets">
         <iframe src="someurl" frameborder="0" id="ticketFrame"></iframe>
      </div>
   </div>
</div>

我很喜欢使用显示内联块和向左浮动,如您所见;)

如何在 phonegap 中使用触摸屏滚动?

【问题讨论】:

  • iframe中内容的高度是否大于1000px?如果没有,将没有任何内容可滚动。您是否尝试将 iframe 的高度设置为 100%?
  • @DawsonLoudon thx,刚刚尝试过,但不行,不起作用..仍然无法滚动。虽然如果它是 1000px,它超出了手机屏幕的高度,所以它应该仍然是滚动的。也许不是框架本身,但确定父母应该是对的吗?就像我说的,当我触摸侧面的父母时,我可以滚动(避开框架)
  • 你在 iframe 上用scrolling="no" 累了 1000px。有时您必须禁用一个元素的滚动才能在父元素上滚动
  • @DawsonLoudon 是的,我有 ;) 但仍然无法工作 ;(
  • 如何使用媒体查询显示两个按钮(上/下)类似于codepen.io/antonlydike/pen/ALWLpq

标签: html ios cordova iframe scroll


【解决方案1】:

也许问题是你的 iframe 标签? &lt;/iframe"&gt;

如果不是,请添加/更改您的 CSS 并重试。

html, body {
    height: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
}

#content_wrap {
    display: inline-block;
    float:left;
    width:100%;
    overflow-x:hidden;
    position:relative;
    height:100%;
    z-index:300;
}

#content_wrap  .content_container {
    position:absolute;
    left:0px;
    display:inline-block;
    float:left;
    width:100%;
    padding:0;
    min-height:100%;
    height:auto;
    background-color:#FFF;
}

#tickets {
    display:inline-block;
    float:left;
    width:50%;
    margin:0px;
    height:100%;
    right: 0; 
    bottom: 0; 
    left: 0;
    top: 0;
    -webkit-overflow-scrolling: touch;
    overflow-y: scroll;
}

#ticketFrame {
    height:1000px;
    display:inline-block;
    float:left;
    width:100%;
}

【讨论】:

  • 感谢您的帮助,但这只是我在堆栈上犯的一个错误,因此这不是我的问题的根源。 (不幸的是)。
  • 您的代码无法在 ios safari 上运行。我认为它不是phonegap问题。我再次编辑css。现在滚动在 ios safari 上工作。可以试试phonegap吗?
  • @MartHaarman 我的代码正在运行 safari mangal.ist/aaa.html 你确定吗?
  • 是的,但不在您为应用程序提供的 css 代码中
  • 所以我将宽度设置为 50%,因此我的 iframe 右侧有一个空白区域。奇怪的是,当我在这个白色区域上滚动时,整个东西都会垂直滚动。但是,当我用手指滚动 iframe 本身时,它什么也没做。
猜你喜欢
  • 2015-11-23
  • 1970-01-01
  • 1970-01-01
  • 2014-11-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-13
  • 2015-06-19
相关资源
最近更新 更多