iOS系统(iPad、iPhone)不支持iframe或div出现滚动条,这个问题困扰了我好久,终于在网上发现了解决办法。
iScroll.js,一个纯js文件,用于解决上述问题。
这里有几种不同的特效:
Pinch / Zoom
Pull up/down to refresh
Improved speed and momentum
Snap to element
Customizable scrollbars
滚动特效:http://cubiq.org/dropbox/iscroll4/examples/simple/
滚动刷新:http://cubiq.org/dropbox/iscroll4/examples/pull-to-refresh/
两指缩放:http://cubiq.org/dropbox/iscroll4/examples/zoom/
滚动切换:http://cubiq.org/dropbox/iscroll4/examples/carousel/
自定义滚动条样式:http://cubiq.org/dropbox/iscroll4/examples/custom-scrollbar/
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <script src="../JavaScript/iScroll/iscroll.js" type="text/javascript"></script> <script> var myscroll; function loaded() { myscroll = new iScroll("wrapper"); } window.addEventListener("DOMContentLoaded", loaded, false); </script>
#wrapper { position: absolute; z-index: 1; top: 45px; bottom: 48px; left: 0; width: 100%; background: #aaa; overflow: auto; } #scroller { position: absolute; z-index: 1; /* -webkit-touch-callout:none;*/ -webkit-tap-highlight-color: rgba(0,0,0,0); width: 100%; padding: 0; }
<div id="wrapper"> <div id="scroller"> 内容 </div> </div>