Skip to content

Commit 43b680c

Browse files
committed
update name
1 parent 84a12ea commit 43b680c

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

e/24/index.html

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>字母上下间歇滚动</title>
6+
<link rel="stylesheet" type="text/css" href="../../css/reset.css" media="all"/>
7+
<style type="text/css">
8+
.outer{ width:500px;margin: 30px auto; overflow:hidden;}
9+
</style>
10+
</head>
11+
<body>
12+
<div id="wrap" class="outer">
13+
<ul id="list" class="list">
14+
<li>春天的江潮水势浩荡,与大海连成一片</li>
15+
<li>一轮明月从海上升起,好像与潮水一起涌出来。</li>
16+
<li>月光照耀着春江,随着波浪闪耀千万里,所有地方的春江都有明亮的月光。</li>
17+
<li>江水曲曲折折地绕着花草丛生的原野流淌,</li>
18+
<li>月光照射着开遍鲜花的树林好像细密的雪珠在闪烁。</li>
19+
<li>月色如霜,所以霜飞无从觉察。</li>
20+
<li>洲上的白沙和月色融合在一起,看不分明。</li>
21+
<li>江水、天空成一色,没有一点微小灰尘,</li>
22+
<li>明亮的天空中只有一轮孤月高悬空中。</li>
23+
<li>江边上什么人最初看见月亮,江上的月亮哪一年最初照耀着人?</li>
24+
</ul>
25+
</div>
26+
<script>
27+
(function(){
28+
var wrap = document.getElementById('wrap');
29+
var list = document.getElementById('list');
30+
var li = list.getElementsByTagName('li');
31+
var first = list.children[0];
32+
var height = first.offsetHeight;
33+
var outHeight = wrap.offsetHeight;
34+
function css(obj, attr){
35+
if(obj.currentStyle){
36+
return obj.currentStyle[attr];
37+
} else {
38+
return window.getComputedStyle(obj, false)[attr];
39+
}
40+
}
41+
function animate(obj, attr, target){
42+
clearInterval(obj.timer);
43+
obj.timer = setInterval(function(){
44+
var stop = true;
45+
var cur = parseInt(css(obj, attr));
46+
var speed = (target - cur) / 8;
47+
speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
48+
if(target != cur){
49+
stop = false;
50+
}
51+
cur += speed;
52+
obj.style[attr] = cur + 'px';
53+
if(stop){
54+
clearInterval(obj.timer);
55+
obj.timer = null;
56+
}
57+
}, 30);
58+
}
59+
var i = 0;
60+
var timer = setInterval(function(){
61+
if(i == li.length){
62+
clearInterval(timer);
63+
}
64+
animate(list, 'marginTop', -(height * i++));
65+
}, 1000);
66+
}());
67+
</script>
68+
</body>
69+
</html>

0 commit comments

Comments
 (0)