I have made a carousel image case for your reference. Thank you for your advice.
<! DOCTYPE html>
<Html lang = "en">
<Head>
<Meta charset = "UTF-8">
<Title> slideshow </title>
<Script>
Window. onload = function (){
Var config = [
{
"Top": 0,
"Left": 0,
"Opacity": 0.3,
"ZIndex": 1
}, // 0
{
& Quot; top & quot;: 120,
"Left": 100,
"Opacity": 0.5,
"ZIndex": 2
}, // 1
{
// "Width": 200,
& Quot; top & quot;: 240,
"Left": 200,
"Opacity": 1,
"ZIndex": 3
}, // 2
{
// "Width": 150,
& Quot; top & quot;: 320,
"Left": 100,
"Opacity": 0.5,
"ZIndex": 2
}, // 3
{
// "Width": 100,
& Quot; top & quot;: 407,
"Left": 0,
"Opacity": 0.3,
"ZIndex": 1
}, // 4
{
// "Height": 100,
// "Width": 100,
& Quot; top & quot;: 407,
"Left":-200,
"Opacity": 0.3,
"ZIndex": 1
}, // 5
{
// "Width": 150,
& Quot; top & quot;: 320,
"Left":-300,
"Opacity": 0.5,
"ZIndex": 2
}, // 6
{
// "Width": 200,
& Quot; top & quot;: 240,
"Left":-400,
"Opacity": 1,
"ZIndex": 3
}, // 7
{
// "Width": 150,
& Quot; top & quot;: 120,
"Left":-300,
"Opacity": 0.5,
"ZIndex": 2
}, // 8
{
// "Width": 100,
"Top": 0,
"Left":-200,
"Opacity": 0.3,
"ZIndex": 1
}, // 9
];
Var pictures = document. getElementById ("pic ");
Var ul = pictures. children [0];
Var ulLis = ul. children;
Var ol = pictures. children [1];
Var olLis = ol. children;
Function assign (){
For (var I = 0; I <ulLis. length; I ++ ){
Animate (ulLis [I], config [I]);
Flag = true;
}
}
Assign ();
Var imgWidth = olLis [0]. offsetWidth;
Var index = 0;
Var timer1 = null;
Var timer2 = null;
Timer1 = setInterval (function (){
Config. push (config. shift ());
// IndexNum ++;
// Console. log (indexNum );
For (var I = 0; I <ulLis. length; I ++ ){
Animate (ulLis [I], config [I]);
}
Index ++;
If (index = 6 ){
Ol. style. left = 0;
Index = 1;
}
},4000 );
Timer2 = setInterval (function (){
If (index <6 ){
Var target =-imgWidth * index;
Cutton (ol, target, 20 );
}
},2000 );
For (var k = 0; k <ulLis. length; k ++ ){
UlLis [k]. onmouseover = function (){
ClearInterval (timer1 );
ClearInterval (timer2 );
}
UlLis [k]. onmouseout = function (){
Timer1 = setInterval (function (){
Config. push (config. shift ());
For (var I = 0; I <ulLis. length; I ++ ){
Animate (ulLis [I], config [I]);
}
Index ++;
If (index = 6 ){
Ol. style. left = 0;
Index = 1;
}
},4000 );
Timer2 = setInterval (function (){
If (index <6 ){
Var target =-imgWidth * index;
Cutton (ol, target, 20 );
}
},2000 );
}
};
Function animate (obj, json, fn ){
ClearInterval (obj. timer );
Obj. timer = setInterval (function (){
Var flag = true;
For (var k in json ){
If (k = "opacity "){
Var leader = getStyle (obj, k) * 100;
Var target = json [k] * 100;
Var step = (target-leader)/10;
Step = step> 0? Math. ceil (step): Math. floor (step );
Leader = leader + step;
Obj. style [k] = leader/100;
} Else if (k = "zIndex "){
Obj. style. zIndex = json [k];
} Else {
Var leader = parseInt (getStyle (obj, k) | 0;
Var target = json [k];
Var step = (target-leader)/10;
Step = step> 0? Math. ceil (step): Math. floor (step );
Leader = leader + step;
Obj. style [k] = leader + "px ";
}
If (leader! = Target ){
Flag = false;
}
}
If (flag ){
ClearInterval (obj. timer );
If (fn ){
Fn ();
}
}
}, 15 );
}
Var flag = true;
For (var num = 0; num <ulLis. length; num ++ ){
UlLis [num]. onclick = function (){
If (flag ){
Flag = false;
If (this. offsetTop = 0 ){
Flag = true;
Config. push (config. shift ());
Config. push (config. shift ());
Assign ();
Index = index + 2;
If (index = 6 ){
Ol. style. left = 0;
Index = 1;
}
If (index <6 ){
Var target =-imgWidth * index;
Animate (ol, {left: target });
}
Console. log (index );
} // 1
If (this. offsetTop = 120 ){
Flag = true;
Config. push (config. shift ());
Assign ();
Index = index + 1;
If (index = 6 ){
Ol. style. left = 0;
Index = 1;
}
If (index <6 ){
Var target =-imgWidth * index;
Animate (ol, {left: target });
}
} // 2
If (this. offsetTop = 320 ){
Flag = true;
// If (indexNum> 0 ){
Config. unshift (config. pop ());
Assign ();
Index = index-1;
Console. log (index );
If (index <0 ){
Index = index + 5;
}
If (index = 6 ){
Ol. style. left = 0;
Index = 1;
}
If (index <6 ){
Var target =-imgWidth * index;
Animate (ol, {left: target });
}
// IndexNum = indexNum-1;
//}
} // 4
If (this. offsetTop = 407 ){
Flag = true;
// If (indexNum> 1 ){
Config. unshift (config. pop ());
Config. unshift (config. pop ());
Assign ();
Index = index-2;
If (index <0 ){
Index = index + 5;
}
If (index = 6 ){
Ol. style. left = 0;
Index = 1;
}
If (index <6 ){
Var target =-imgWidth * index;
Animate (ol, {left: target });
}
} // 5
}
}
}
}
</Script>
</Head>
<Body>
<Div class = "pictures" id = "pic">
<Ul>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
</Ul>
<Ol>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
<Li> <a href = "javascript: void (0);"> </a> </li>
</Ol>
</Div>
</Body>
</Html>