Native js carousel image, js Wheel
// Use native js to implement a simple carousel Image
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Title> </title>
<Style type = "text/css">
*{
Margin: 0;
Padding: 0;
}
# Banner {
Position: relative;
}
# List {
Width: 750px;
Height: 500px;
Margin: 100px auto;
}
# List img {
Display: block;
}
# List1 {
Position: absolute;
Bottom: 10px;
Left: 50%;
Margin-left:-75px;
}
# List1 li {
List-style: none;
Width: 20px;
Height: 20px;
Border-radius: 20px;
Background: #000;
Opacity:. 4;
Filter: alpha (opacity = 40 );
Float: left;
Margin-left: 10px;
Cursor: pointer;
}
# Banner {
Display: block;
Width: 30px;
Height: 30px;
Background: #000;
Opacity:. 4;
Position: absolute;
Top: 50%;
Margin-top:-15px;
Text-decoration: none;
Color: # fff;
Font-size: 20px;
Font-weight: 600;
Line-height: 30px;
Text-align: center;
}
# Left {
Left: 21%;
}
# Right {
Right: 21%;
}
# List1. li {
Background: # f40;
}
# Box {
Width: 750px;
Height: 500px;
Margin: 0 auto;
}
</Style>
</Head>
<Body>
<Div id = "banner">
<Div id = "box">
<Div id = "list">
</Div>
<A href = "javascript:;" id = "left"> </a>
<A href = "javascript:;" id = "right" >></a>
</Div>
<Ul id = "list1">
<Li class = "li"> </li>
<Li> </li>
<Li> </li>
<Li> </li>
<Li> </li>
</Ul>
</Div>
<Script type = "text/javascript">
Var oList = document. getElementById ("list ");
Var oList1 = document. getElementById ("list1 ");
Var oLi = document. getElementsByTagName ('lil ');
Var oPic = document. getElementById ("pic ");
Var Left = document. getElementById ("left ");
Var Right = document. getElementById ("right ");
Var box = document. getElementById ("box ");
Num = 1;
Var timer = setInterval (function (){
Num ++;
If (num> 5 ){
Num = 1;
}
Fn ();
}, 2000)
OList. onmouseout = function (){
Timer = setInterval (function (){
Num ++;
If (num> 5 ){
Num = 1;
}
Fn ();
}, 2000)
}
Box. onmouseover = function (){
ClearInterval (timer );
}
Right. onclick = function (){
Num ++;
If (num> 5 ){
Num = 1;
}
Fn ();
}
Left. onclick = function (){
Num --;
If (num <1 ){
Num = 5;
}
Fn ();
}
For (var I = 0; I <oLi. length; I ++ ){
OLi [I]. index = I;
OLi [I]. onclick = function (){
Num = this. index + 1;
Fn ();
}
}
Function fn (){
OPic. src = "img/" + num + ". jpg ";
For (var I = 0; I <oLi. length; I ++ ){
OLi [I]. className = '';
If (num = I + 1 ){
OLi [I]. style. background = '# f40 ';
} Else {
OLi [I]. style. background = '';
}
}
}
</Script>
</Body>
</Html>