-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
45 lines (43 loc) · 876 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{margin:0;}
.animate{transition:all .5s;}
.item{
position:relative;
top:0;
width:98%;
height:50px;
margin:1%;
border:1px solid #ccc;
border-radius:5px;
}
</style>
</head>
<body>
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<script>
var height = $('.item')[0].offsetTop;
[].forEach.call($('.item'), function(e){
e.style.top = height - e.offsetTop + 'px';
});
setTimeout(function(){
[].forEach.call($('.item'), function(e){
e.className = e.className + ' animate';
e.style.top = 0;
});
}, 0);
function $(str){
var objs = document.querySelectorAll(str)
return objs.length == 1 ? objs[0] : objs;
}
</script>
</body>
</html>