1

我正在使用 Phonegap 开发一个应用程序。

我有十张图片,我正在使用 iscroll5 滚动它们。有时快照会跳过一些 img 元素,我不确定它为什么会这样做。图像有不同的尺寸。

这是我使用的代码片段:

  <html>
      <head>
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0, user- scalable=0, minimum-scale=1.0, maximum-scale=1.0">

       <title>iScroll demo: carousel</title>

     <script type="text/javascript" src="iscroll.js"></script>

  <script type="text/javascript">

  var myScroll;

   function loaded () {
        myScroll = new IScroll('#wrapper', {
    scrollX: true,
    scrollY: false,
    momentum: false,
    snap:"img",
    snapSpeed: 400,
    keyBindings: true

});

}

   document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
  </script>


  <style type="text/css">
  #wrapper {
width: 200px;
height: 240px;
margin: 0 auto;
  }

  #scroller {
   position: absolute;
   z-index: 1;
   -webkit-tap-highlight-color: rgba(0,0,0,0);
   width: 800px;
   height: 240px;
  -webkit-transform: translateZ(0);
   -moz-transform: translateZ(0);
  -ms-transform: translateZ(0);
  -o-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: none;
  -moz-text-size-adjust: none;
  -ms-text-size-adjust: none;
  -o-text-size-adjust: none;
  text-size-adjust: none;
  background-color: #444;
    }

  #scroller img{
        margin:0px;
        padding:0px;

            }

     </style>
           </head>

 <body onload="loaded()">

              <div id="wrapper">
                       <div id="scroller">
                         <div><img src="img1.png></div>
                          <div><img src="img2.png></div>
                                      <div><img src="img3.png></div>
                                      <div><img src="img4.png></div>
                          <div><img src="img5.png></div>
                          <div><img src="img6.png></div>
                                      <div><img src="img7.png></div>
                                      <div><img src="img8.png></div>
                          <div><img src="img9.png></div>
                           <div><img src="img10.png></div>

    </div>
  </div>

                </body>
                      </html>
4

0 回答 0