-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathseparate.html
More file actions
63 lines (51 loc) · 1.24 KB
/
Copy pathseparate.html
File metadata and controls
63 lines (51 loc) · 1.24 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src = "jquery-1.11.3.min.js"></script>
<script>
$(function(){
for(var i = 0 ;i<1225;i++){
var x = i%35;
var y = parseInt(i/35)
$("<div class='item'></div>").css({
"background":"url(img/1.jpg) no-repeat",
"background-position":x*(-49)+"px "+y*(-25)+"px",
"left":x*49+"px",
"top":y*25+"px"
}).appendTo($("#box"))
}
var nosplict = true
$("#box").click(function(){
if(nosplict){
$(".item").each(function(index,element){
var xnum = Math.random()*6000-3000
var ynum = Math.random()*6000-3000
$(this).css(
{"transform":"translate("+xnum+"px,"+ynum+"px)"}
)
})
}else{
$(".item").each(function(){
$(this).css(
{"transform":"translate(0px,0px)"}
)
})
}
nosplict=!nosplict
})
})
</script>
<style>
body{overflow: hidden;}
#box{width: 980px;height: 500px;background-color: #fff;}
.center{position: absolute;left: 0;top:0;right:0;bottom:0;margin:auto}
.item{width: 49px;height: 25px;position: absolute;transition: transform 2s;}
</style>
</head>
<body>
<div id="box" class="center">
</div>
</body>
</html>