-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangImages.html
More file actions
86 lines (85 loc) · 1.9 KB
/
changImages.html
File metadata and controls
86 lines (85 loc) · 1.9 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
85
86
<!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;
}
.c_father {
height: 617px;
width: 500px;
box-sizing: border-box;
/*margin: 80px auto;*/
margin: 45px auto;
margin-left: 325px;
}
#i_top {
height: 60px;
width: 500px;
margin-bottom: 5px;
text-align: left;
line-height: 60px;
font-size: 30px;
font-family: "宋体";
color: orange;
}
#i_cont {
height: 400px;
width: 500px;
margin-bottom: 20px;
}
#i_cont .c_big {
height: 400px;
width: 678px;
}
#i_bot {
height: 100px;
width: 745px;
}
#i_bot .c_small {
height: 63px;
width: 116px;
float: left;
margin-left: 15px;
cursor: pointer;
}
</style>
<script>
window.onload = function () {
var aImgs = document.getElementsByTagName('img');
var oBig = aImgs[0];
var oSpa = document.getElementsByTagName('span')[0];
for (var i = 1; i < aImgs.length; i++) {
aImgs[i].onclick = function () {
var oSrc = this.getAttribute("src");
var oDec = this.getAttribute("dec");
oBig.setAttribute("src", oSrc);
oSpa.innerText = oDec;
};
}
};
</script>
</head>
<body>
<div id="i_father" class="c_father">
<div id="i_top">
<span>一段描述</span>
</div>
<div id="i_cont">
<img src="images/风景1.jpg" alt="" class="c_big">
</div>
<div id="i_bot">
<img src="images/风景1.jpg" alt="" class="c_small" id="i_img1" dec="大山">
<img src="images/风景2.jpg" alt="" class="c_small" dec="法国建筑">
<img src="images/风景3.jpg" alt="" class="c_small" dec="宇宙星空">
<img src="images/风景4.jpg" alt="" class="c_small" dec="神奇建筑">
<img src="images/风景5.jpg" alt="" class="c_small" dec="护城河畔">
</div>
</div>
</body>
</html>