-
Notifications
You must be signed in to change notification settings - Fork 0
/
test01.html
75 lines (67 loc) · 2.2 KB
/
test01.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test01</title>
<style>
body {
text-align: center;
}
.btn {
background-color: #f9ca24;
color: white;
padding: 15px 15px;
margin-top: 20px;
border: 0;
border-radius: 5px;
cursor: pointer;
box-shadow: 0 3px rgba(249, 202, 36, 0.5);
}
.btn:active {
transform: translateY(3px);
box-shadow: none;
}
.container {
margin: 20px auto;
width: 400px;
height: 400px;
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
.container>div {
background-image: url("images/cat.gif");
background-repeat: no-repeat;
background-size: 400px 400px;
width: 130px;
height: 130px;
transition: 1.2s ease;
}
</style>
</head>
<body>
<button class="btn" onclick="reversePng()">点击有效果哦~</button>
<div id="a" class="container">
<div style="background-position: 0 0;"></div>
<div style="background-position: -130px 0;"></div>
<div style="background-position: -260px 0;"></div>
<div style="background-position: 0 -130px;"></div>
<div style="background-position: -130px -130px;"></div>
<div style="background-position: -260px -130px;"></div>
<div style="background-position: -0px -260px;"></div>
<div style="background-position: -130px -260px;"></div>
<div style="background-position: -260px -260px;"></div>
</div>
</body>
<script>
var r = 0
function reversePng() {
r += 360
var alldivs = document.getElementsByClassName("container")[0];
for (var i = 0; i < 9; i++)
alldivs.children[i].style.transform = 'rotate(' + r + 'deg)';
}
</script>
</html>