-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangeBackGround.html
More file actions
84 lines (83 loc) · 1.86 KB
/
changeBackGround.html
File metadata and controls
84 lines (83 loc) · 1.86 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>网页换肤</title>
<link rel="stylesheet" href="">
<style>
* {
margin: 0;
padding: 0;
list-style: none;
vertical-align: top;
}
body{
background: url("background/back1.jpg");
}
.c_father {
position: relative;
height: 100%;
width: 100%;
}
ul {
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
display: none;
}
ul li img {
margin-top: 30px;
height: 118px;
width: 178px;
cursor: pointer;
}
.c_icons {
position: absolute;
width: 50px;
height: 50px;
left: 45%;
cursor: pointer;
}
</style>
<script>
window.onload = function () {
var oImg = document.getElementById("i_son");
var aImgs = oImg.getElementsByTagName("img");
var oDiv = document.getElementById("i_father");
for (var i = 0; i < aImgs.length; i++) {
aImgs[i].index = i + 1;
aImgs[i].onclick = function () {
document.body.style.background = 'url("background/back'+ this.index +'.jpg")';
};
}
var oIcon = document.getElementById("i_icons");
var oUl = document.getElementById("i_img");
oIcon.index = 0;
oIcon.onclick = function () {
if (this.index % 2 === 0) {
oUl.style.display = "flex";
} else {
oUl.style.display = "none";
}
this.index ++;
};
};
</script>
</head>
<body>
<div id="i_father" class="c_father">
<div id="i_son" claas="c_son">
<ul id="i_img">
<li><img src="background/back1.jpg" alt=""></li>
<li><img src="background/back2.jpg" alt=""></li>
<li><img src="background/back3.jpg" alt=""></li>
<li><img src="background/back4.jpg" alt=""></li>
<li><img src="background/back5.jpg" alt=""></li>
</ul>
</div>
<img src="icons/down.png" alt="" id="i_icons" class="c_icons">
</div>
</body>
</html>