【问题标题】:Can't Scroll Up or Down Within a Horizontal Scroller on Mobile无法在移动设备上的水平滚动器内向上或向下滚动
【发布时间】:2015-08-15 03:45:23
【问题描述】:

我有一个在移动设备上使用的应用。我有一个简单的水平滚动和一些文本。如果用户在水平滚动条之外向上或向下滑动,则页面会上下滑动。但是,当用户在水平滚动条内用手指向上或向下滑动时,页面不会向上或向下滑动。我想让它向上或向下滑动。下面是codepen

这里是代码。

<ion-scroll direction="x" class="wide-as-needed">
    <a class="button inline-button">this is a button : 1</a>
    <a class="button">this is a button : 2</a>
    <a class="button">this is a button : 3</a>
    <a class="button">this is a button : 4</a>
    <a class="button">this is a button : 5</a>
    <a class="button">this is a button : 6</a>
    <a class="button">this is a button : 7</a>
    <a class="button">this is a button : 8</a>
    <a class="button">this is a button : 9</a>
    <a class="button">this is a button : 10</a>
    <a class="button">this is a button : 11</a>
    <a class="button">this is a button : 12</a>
    <a class="button">this is a button : 13</a>
    <a class="button">this is a button : 14</a>
    <a class="button">this is a button : 15</a>
    <a class="button">this is a button : 16</a>
  </ion-scroll>

  <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>

  <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>

  <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>

  <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>

  <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>

CSS

.wide-as-needed {
  overflow: scroll;
  white-space: nowrap;
}

.scroll { 
  min-width: 100%;
}

【问题讨论】:

标签: html css ionic-framework horizontal-scrolling


【解决方案1】:

您应该能够将overflow-scroll="true" 添加到您的&lt;ion-content&gt;&lt;/ion-content&gt; 标记中,所以它看起来像这样:

<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 

    <title>Ionic Modal</title>

    <link href="http://code.ionicframework.com/nightly/css/ionic.min.css" rel="stylesheet">
    <script src="http://code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
  </head>
  <body ng-controller="MainCtrl">

    <ion-header-bar class="bar-positive">
      <h1 class="title">Hello!</h1>
    </ion-header-bar>
    <ion-header-bar class="bar-subheader">

    </ion-header-bar>
    <div class="bar bar-loading bar-assertive" ng-if="data.isLoading">
      Loading...
    </div>
    <ion-content overflow-scroll="true" ng-class="{'has-loading': data.isLoading}">

        <ion-scroll direction="x" class="wide-as-needed">
        <a class="button inline-button">this is a button : 1</a>
        <a class="button">this is a button : 2</a>
        <a class="button">this is a button : 3</a>
        <a class="button">this is a button : 4</a>
        <a class="button">this is a button : 5</a>
        <a class="button">this is a button : 6</a>
        <a class="button">this is a button : 7</a>
        <a class="button">this is a button : 8</a>
        <a class="button">this is a button : 9</a>
        <a class="button">this is a button : 10</a>
        <a class="button">this is a button : 11</a>
        <a class="button">this is a button : 12</a>
        <a class="button">this is a button : 13</a>
        <a class="button">this is a button : 14</a>
        <a class="button">this is a button : 15</a>
        <a class="button">this is a button : 16</a>



      </ion-scroll>
      <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>

            <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>

            <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>


            <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>

            <ion-toggle ng-model="data.isLoading">Toggle me to toggle loading!</ion-toggle>
    </ion-content>

  </body>
</html>

编辑

可能找到了一个更好更实用的解决方案,虽然代码很多,所以请参阅http://codepen.io/rajeshwarpatlolla/pen/xGWBja

【讨论】:

  • 这真的很糟糕,我必须实施您提供的编辑解决方案。不过感谢您的帮助。顺便说一句,overflow-scroll="true" 对我不起作用。
猜你喜欢
  • 2017-05-23
  • 1970-01-01
  • 2022-06-24
  • 2021-04-17
  • 2019-05-31
  • 2016-11-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多