![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> 6 <title>iScroll demo: horizontal scrolling</title> 7 <style type="text/css"> 8 * { 9 -webkit-box-sizing: border-box; 10 -moz-box-sizing: border-box; 11 box-sizing: border-box; 12 } 13 html { 14 -ms-touch-action: none; 15 } 16 body,ul,li { 17 padding: 0; 18 margin: 0; 19 border: 0; 20 } 21 body { 22 font-size: 12px; 23 font-family: ubuntu, helvetica, arial; 24 overflow: hidden; 25 } 26 #header { 27 width: 100%; 28 height: 45px; 29 line-height: 45px; 30 background: #CD235C; 31 padding: 0; 32 color: #eee; 33 font-size: 20px; 34 text-align: center; 35 font-weight: bold; 36 } 37 #footer { 38 width: 100%; 39 height: 48px; 40 line-height: 48px; 41 background: #444; 42 padding: 0; 43 border-top: 1px solid #444; 44 text-align: center; 45 color: #Fff; 46 font-size: 18px; 47 } 48 #wrapper { 49 width: 100%; 50 height: 120px; 51 background: magenta; 52 overflow: hidden; 53 } 54 #scroller { 55 margin-top: 10px; 56 -webkit-tap-highlight-color: rgba(0,0,0,0); 57 width: 5000px; 58 height: 100px; 59 background-color: #a00; 60 -webkit-transform: translateZ(0); 61 -moz-transform: translateZ(0); 62 -ms-transform: translateZ(0); 63 -o-transform: translateZ(0); 64 transform: translateZ(0); 65 -webkit-touch-callout: none; 66 -webkit-user-select: none; 67 -moz-user-select: none; 68 -ms-user-select: none; 69 user-select: none; 70 -webkit-text-size-adjust: none; 71 -moz-text-size-adjust: none; 72 -ms-text-size-adjust: none; 73 -o-text-size-adjust: none; 74 text-size-adjust: none; 75 } 76 #scroller ul { 77 list-style: none; 78 padding: 0; 79 margin: 0; 80 width: 100%; 81 height: 100%; 82 text-align: center; 83 } 84 #scroller li { 85 display: block; 86 float: left; 87 width: 100px; 88 height: 100%; 89 border-right: 1px solid #ccc; 90 background-color: #fafafa; 91 font-size: 14px; 92 } 93 img{ 94 width: 100%; 95 height: 100%; 96 } 97 </style> 98 <script type="text/javascript" src="js/iscroll.js"></script> 99 <script type="text/javascript"> 100 var myScroll; 101 function loaded () { 102 myScroll = new IScroll('#wrapper', { 103 scrollX: true, 104 scrollY: false, 105 mouseWheel:false, //是否监听鼠标滚轮事件。TRUE为监听,击鼠标滚动iscroll随着滚动。默认值为FALSE 106 scrollbars:false, //是否显示默认滚动条.false为默认值 不显示。 107 disableMouse:true, 108 tab:true, //设置此属性为true,当滚动区域被点击或者触摸但并没有滚动时,可以让iScroll抛出一个自定义的tap事件。 109 preventDefault:false //当事件触发时师傅执行preventDefault()。此属性应该设置为true,除非你真的知道你需要怎么做。 110 }); 111 } 112 </script> 113 </head> 114 <body onload="loaded()"> 115 <div id="header">iScroll-左右滑动demo</div> 116 <div id="wrapper"> 117 <div id="scroller"> 118 <ul> 119 <li><img src="img/01_m.jpg"/></li> 120 <li><img src="img/1_m.jpg"/></li> 121 <li><img src="img/01_m.jpg"/></li> 122 <li><img src="img/1_m.jpg"/></li> 123 <li><img src="img/01_m.jpg"/></li> 124 <li><img src="img/1_m.jpg"/></li> 125 <li><img src="img/01_m.jpg"/></li> 126 <li><img src="img/1_m.jpg"/></li> 127 <li><img src="img/01_m.jpg"/></li> 128 <li><img src="img/1_m.jpg"/></li> 129 <li><img src="img/01_m.jpg"/></li> 130 <li><img src="img/1_m.jpg"/></li> 131 <li><img src="img/01_m.jpg"/></li> 132 <li><img src="img/1_m.jpg"/></li> 133 <li><img src="img/01_m.jpg"/></li> 134 <li><img src="img/1_m.jpg"/></li> 135 <li><img src="img/01_m.jpg"/></li> 136 <li><img src="img/1_m.jpg"/></li> 137 <li><img src="img/01_m.jpg"/></li> 138 <li><img src="img/1_m.jpg"/></li> 139 <li><img src="img/01_m.jpg"/></li> 140 <li><img src="img/1_m.jpg"/></li> 141 <li><img src="img/01_m.jpg"/></li> 142 <li><img src="img/1_m.jpg"/></li> 143 <li><img src="img/01_m.jpg"/></li> 144 <li><img src="img/1_m.jpg"/></li> 145 <li><img src="img/01_m.jpg"/></li> 146 <li><img src="img/1_m.jpg"/></li> 147 <li><img src="img/01_m.jpg"/></li> 148 <li><img src="img/1_m.jpg"/></li> 149 <li><img src="img/01_m.jpg"/></li> 150 <li><img src="img/1_m.jpg"/></li> 151 <li><img src="img/01_m.jpg"/></li> 152 <li><img src="img/1_m.jpg"/></li> 153 <li><img src="img/01_m.jpg"/></li> 154 <li><img src="img/1_m.jpg"/></li> 155 <li><img src="img/01_m.jpg"/></li> 156 <li><img src="img/1_m.jpg"/></li> 157 <li><img src="img/01_m.jpg"/></li> 158 <li><img src="img/1_m.jpg"/></li> 159 <li><img src="img/01_m.jpg"/></li> 160 <li><img src="img/1_m.jpg"/></li> 161 <li><img src="img/01_m.jpg"/></li> 162 <li><img src="img/1_m.jpg"/></li> 163 <li><img src="img/01_m.jpg"/></li> 164 <li><img src="img/1_m.jpg"/></li> 165 <li><img src="img/01_m.jpg"/></li> 166 <li><img src="img/1_m.jpg"/></li> 167 <li><img src="img/01_m.jpg"/></li> 168 <li><img src="img/1_m.jpg"/></li> 169 </ul> 170 </div> 171 </div> 172 <div id="footer">iScroll demo: horizontal scrolling</div> 173 <div id="footer">iScroll demo: horizontal scrolling</div> 174 <div id="footer">iScroll demo: horizontal scrolling</div> 175 <div id="footer">iScroll demo: horizontal scrolling</div> 176 <div id="footer">iScroll demo: horizontal scrolling</div> 177 <div id="footer">iScroll demo: horizontal scrolling</div> 178 <div id="footer">iScroll demo: horizontal scrolling</div> 179 <div id="footer">iScroll demo: horizontal scrolling</div> 180 <div id="footer">iScroll demo: horizontal scrolling</div> 181 <div id="footer">iScroll demo: horizontal scrolling</div> 182 <div id="footer">iScroll demo: horizontal scrolling</div> 183 <div id="footer">iScroll demo: horizontal scrolling</div> 184 <div id="footer">iScroll demo: horizontal scrolling</div> 185 <div id="footer">iScroll demo: horizontal scrolling</div> 186 <div id="footer">iScroll demo: horizontal scrolling</div> 187 <div id="footer">iScroll demo: horizontal scrolling</div> 188 <div id="footer">iScroll demo: horizontal scrolling</div> 189 <div id="footer">iScroll demo: horizontal scrolling</div> 190 <div id="footer">iScroll demo: horizontal scrolling</div> 191 <div id="footer">iScroll demo: horizontal scrolling</div> 192 <div id="footer">iScroll demo: horizontal scrolling</div> 193 <div id="footer">iScroll demo: horizontal scrolling</div> 194 <div id="footer">iScroll demo: horizontal scrolling</div> 195 <div id="footer">iScroll demo: horizontal scrolling</div> 196 <div id="footer">iScroll demo: horizontal scrolling</div> 197 <div id="footer">iScroll demo: horizontal scrolling</div> 198 <div id="footer">iScroll demo: horizontal scrolling</div> 199 <div id="footer">iScroll demo: horizontal scrolling</div> 200 <div id="footer">iScroll demo: horizontal scrolling</div> 201 <div id="footer">iScroll demo: horizontal scrolling</div> 202 <div id="footer">iScroll demo: horizontal scrolling</div> 203 <div id="footer">iScroll demo: horizontal scrolling</div> 204 <div id="footer">iScroll demo: horizontal scrolling</div> 205 </body> 206 </html>
解决iscroll的点击为双击问题! 引入:fastclick.js