-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpic_slide.html
More file actions
223 lines (223 loc) · 9.19 KB
/
Copy pathpic_slide.html
File metadata and controls
223 lines (223 loc) · 9.19 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.d1 {
width: 443px;
height: auto;
overflow: hidden;
border: #666666 2px solid;
background-color: #000000;
position: relative;
}
.loading{
width: 443px;
border: #666666 2px solid;
background-color: #000000;
color: #FFCC00;
font-size: 12px;
height: 179px;
text-align: center;
padding-top: 30px;
font-weight: bold;
}
.d2 {
width: 100%;
height: 209px;
overflow: hidden;
}
.num_list {
position: absolute;
width: 100%;
left: 0px;
bottom: -1px;
background-color: #000000;
color: #FFFFFF;
font-size: 12px;
padding: 4px 0px;
height: 20px;
overflow: hidden;
}
.num_list span {
display: inline-block;
height: 16px;
padding-left: 6px;
}
img {
border: 0px;
}
ul {
display: none;
}
.button {
position: absolute;
z-index: 1000;
right: 0px;
bottom: 2px;
font-size: 13px;
font-weight: bold;
}
.b1 {
background-color: #666666;
display: block;
float: left;
padding: 2px 6px;
margin-right: 3px;
color: #FFFFFF;
text-decoration: none;
cursor: pointer;
}
.b2 {
display: block;
float: left;
padding: 2px 6px;
margin-right: 3px;
text-decoration: none;
cursor: pointer;
color:#FFCC33;
background-color:#FF6633;
}
</style>
<script language="javascript" type="text/javascript">
//主函数
var s=function(){
var interv=2000; //切换间隔时间
var interv2=10; //切换速度
var opac1=80; //文字背景的透明度
var source="show" //焦点轮换图片容器的id名称
//获取对象
function getTag(tag,obj){
if(obj==null){
return document.getElementsByTagName(tag);
}else{
return obj.getElementsByTagName(tag);
}
}
function getid(id){
return document.getElementById(id);
};
var opac=0,j=0,t=63,num,scton=0,timer,timer2,timer3;
var id=getid(source);
id.removeChild(getTag("div",id)[0]);
var li=getTag("li",id);
var div=document.createElement("div");
var title=document.createElement("div");
var span=document.createElement("span");
var button=document.createElement("div");
button.className="button";
for(var i=0;i<li.length;i++){
var a=document.createElement("a");
a.innerHTML=i+1;
a.onclick=function(){
clearTimeout(timer);
clearTimeout(timer2);
clearTimeout(timer3);
j=parseInt(this.innerHTML)-1;
scton=0;
t=63;
opac=0;
fadeon();
};
a.className="b1";
a.onmouseover=function(){
this.className="b2";
};
a.onmouseout=function(){
this.className="b1";sc(j);
};
button.appendChild(a);
}
//控制图层透明度
function alpha(obj,n){
if(document.all){
obj.style.filter="alpha(opacity="+n+")";
}else{
obj.style.opacity=(n/100);
}
}
//控制焦点按钮
function sc(n){
for(var i=0;i<li.length;i++){
button.childNodes[i].className="b1";
};
button.childNodes[n].className="b2";
}
title.className="num_list";
title.appendChild(span);
alpha(title,opac1);
id.className="d1";
div.className="d2";
id.appendChild(div);
id.appendChild(title);
id.appendChild(button);
//渐显
var fadeon=function(){
opac+=5;
div.innerHTML=li[j].innerHTML;
span.innerHTML=getTag("img",li[j])[0].alt;
alpha(div,opac);
if(scton==0){
sc(j);
num=-2;
scrolltxt();
scton=1;
};
if(opac<100){
timer=setTimeout(fadeon,interv2);
}else{
timer2=setTimeout(fadeout,interv);
}
};
//渐隐
var fadeout=function(){
opac-=5;
div.innerHTML=li[j].innerHTML;
alpha(div,opac);
if(scton==0){
num=2;
scrolltxt();
scton=1;
}
if(opac>0){
timer=setTimeout(fadeout,interv2);
}else{
if(j<li.length-1){
j++;
}else{
j=0;
}
fadeon();
}
};
//滚动文字
var scrolltxt=function(){
t+=num;
span.style.marginTop=t+"px";
if(num<0 && t>3){
timer3=setTimeout(scrolltxt,interv2);
}else if(num>0 && t<62){
timer3=setTimeout(scrolltxt,interv2);
}else{
scton=0
}
};
fadeon();
}
//初始化
window.onload=s;
</script>
<title>图片幻灯效果</title>
</head>
<body>
<div id="show">
<div class="loading">Loading...<br /><img src="./images/01.jpg" width="100" height="100" /></div>
<ul>
<li><a href="article/1" target="_blank"><img src="./images/01.jpg" width="443" height="209" alt="展示图片1" /></a></li>
<li><a href="article/2" target="_blank"><img src="./images/02.jpg" width="443" height="209" alt="展示图片2" /></a></li>
<li><a href="article/3" target="_blank"><img src="./images/03.jpg" width="443" height="209" alt="展示图片3" /></a></li>
<li><a href="article/4" target="_blank"><img src="./images/04.jpg" width="443" height="209" alt="展示图片4" /></a></li>
</ul>
</div>
</body>
</html>