<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, 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-translucent" />
<title>Scrolling DIV demo on iPhone / iPod Touch / Android / iPad</title>
<script type="text/javascript" src="../../src/iscroll.js?v3.5"></script>
<script type="text/javascript">
var myScroll;
function setHeight() {
var headerH = document.getElementById('header').offsetHeight;
var footerH = document.getElementById('footer').offsetHeight;
var wrapperH = window.innerHeight - headerH - footerH;
document.getElementById('wrapper').style.height = wrapperH + 'px';
}
function loaded() {
setHeight();
myScroll = new iScroll('scroller');
/* myScroll = myScroll.destroy(); // Destroy the iScroll */
}
window.addEventListener('onorientationchange' in window ? 'orientationchange' : 'resize', setHeight, false);
document.addEventListener('touchstart', function(e){ e.preventDefault(); }, true);
document.addEventListener('DOMContentLoaded', loaded, false);
</script>
<style type="text/css" media="all">
body,ul,li {
padding:0;
margin:0;
border:0;
}
body {
font-size:12px;
-webkit-user-select:none;
-webkit-text-size-adjust:none;
/* -webkit-box-sizing:border-box;*/
font-family:helvetica;
/* padding-bottom:44px; /* This prevents the scroller to lock if the user swipes down outside of the screen.
NOT needed if in home screen mode. */
}
#header {
width:100%;
height:45px;
line-height:45px;
background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #fe96c9), color-stop(0.05, #d51875), color-stop(1, #7b0a2e));
padding:0;
color:#eee;
font-size:20px;
text-align:center;
}
#header a {
color:#f3f3f3;
text-decoration:none;
font-weight:bold;
text-shadow:0 -1px 0 rgba(0,0,0,0.5);
}
#footer {
width:100%;
height:48px;
background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #999), color-stop(0.02, #666), color-stop(1, #222));;
padding:0;
border-top:1px solid #444;
}
#footer li {
display:block;
float:left;
}
#footer li {
width:50%;
text-align:center;
}
#footer a.remove {
border-right:1px solid #333;
}
#footer a.add {
border-left:1px solid #6a6a6a;
}
#footer a {
display:block;
text-decoration:none;
font-size:12px;
color:#eee;
line-height:24px;
text-shadow:0 -1px 0 #000;
}
#footer span {
display:block;
font-size:30px;
font-weight:bold;
}
#wrapper {
height:200px; /* Of course you need to specify the object height */
position:relative; /* On older OS versions "position" and "z-index" must be defined, */
z-index:1; /* it seems that recent webkit is less picky and works anyway. */
width:100%;
background:#aaa;
overflow:hidden;
/* background:#aaa url(wrapper-bg.png);*/
}
#scroller {
/* -webkit-touch-callout:none;*/
/* -webkit-tap-highlight-color:rgba(0,0,0,0);*/
float:left;
width:100%;
padding:0;
/* -webkit-box-shadow:0 0 8px #555; /* Don't use shadows in production, they slow down drastically CSS animations */
}
#scroller ul {
list-style:none;
padding:0;
margin:0;
width:100%;
text-align:left;
}
#scroller li {
padding:0 10px;
height:40px;
line-height:40px;
border-bottom:1px solid #ccc;
border-top:1px solid #fff;
background-color:#fafafa;
/* background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#d4d4d4), to(#fafafa));*/
font-size:14px;
}
fieldset {
display:block; float:left;
width:100%;
}
</style>
</head>
<body>
<div id="header"><a href="http://cubiq.org/iscroll">iScroll</a></div>
<div id="wrapper">
<div id="scroller">
<ul id="thelist">
<li><a href="#" onclick="myScroll.scrollToElement('#row10');return false">Scroll to row 10 (default runtime)</a></li>
<li>Pretty content row 2</li>
<li>Pretty content row 3</li>
<li>Pretty content row 4</li>
<li>Pretty content row 5</li>
<li>Pretty content row 6</li>
<li>Pretty content row 7</li>
<li>Pretty content row 8</li>
<li>Pretty content row 9</li>
<li id="row10"><a href="#" onclick="myScroll.scrollToElement('#scroller > ul > li:last-child', '0s');return false">Go to bottom (skip to, no animation)</a></li>
<li>Scroll to row 1</li>
<li>Pretty content row 12</li>
<li>Pretty content row 13</li>
<li>Pretty content row 14</li>
<li>Pretty content row 15</li>
<li>Pretty content row 16</li>
<li>Pretty content row 17</li>
<li>Pretty content row 18</li>
<li>Pretty content row 19</li>
<li><a href="#" onclick="myScroll.scrollToElement('#scroller > ul > li', '1s');return false">Go back to top (1s runtime)</a></li>
</ul>
</div>
</div>
<div id="footer"><ul><li><a class="remove" href="#" ontouchend="document.getElementById('thelist').removeChild(document.getElementById('thelist').getElementsByTagName('li')[document.getElementById('thelist').getElementsByTagName('li').length-1]);return false;"><span>–</span>remove row</a></li><li><a class="add" href="#" ontouchend="document.getElementById('thelist').appendChild(document.createElement('li')).innerText = 'Pretty content row ' + document.getElementById('thelist').getElementsByTagName('li').length;return false;"><span>+</span>add row</a></li></ul></div>
<div id="test"><div></div></div>
</body>
</html>
- 1
- 2
前往页