This kind of mall has a lot of online effects, but most of them are plug-ins, or JS is too complicated to write. It seems difficult for children's shoes to learn. This looks simple and easy to understand, please watch out for all your children's shoes and comments and paste the code (For ease of use, you can copy the code and use it without adding anything else ):
Copy codeThe Code is as follows:
<! Doctype html>
<Html lang = "en">
<Head>
<Title> simple and practical results of common mall scrolling </title>
<Script type = "text/javascript" src = "http://jt.875.cn/js/jquery.js"> </script>
<Script type = "text/javascript">
$ (Function (){
Var len = $ (". num> li"). length;
Var index = 0;
Var adTimer;
$ (". Num li"). mouseover (function (){
Index = $ (". num li"). index (this );
ShowImg (index );
}). Eq (0). mouseover ();
// Slide in to stop the animation and slide out to start the animation.
$ ('. Ad'). hover (function (){
ClearInterval (adTimer );
}, Function (){
AdTimer = setInterval (function (){
ShowImg (index)
Index ++;
If (index = len) {index = 0 ;}
},3000 );
}). Trigger ("mouseleave ");
})
// Display different slides by controlling the top
Function showImg (index ){
Var adHeight = $ (". content. ad"). height ();
$ (". Slider"). stop (true, false). animate ({top:-adHeight * index}, 1000 );
$ (". Num li"). removeClass ("on ")
. Eq (index). addClass ("on ");
}
</Script>
<Style type = "text/css">
Ul, li {margin: 0; padding: 0 ;}
. Ad {margin-bottom: 10px; width: 586px; height: 150px; overflow: hidden; position: relative ;}
. Content. slider,. content. num {position: absolute ;}
. Content. slider li {list-style: none; display: inline ;}
. Content. slider img {width: 586px; height: 150px; display: block ;}
. Content. num {right: 5px; bottom: 5px ;}
. Content. num li {float: left; color: # FF7300; text-align: center; line-height: 16px; width: 16px; height: 16px; font-family: Arial; font-size: 12px; cursor: pointer; overflow: hidden; margin: 3px 1px; border: 1px solid # FF7300; background-color: # fff;
}
. Content. num li. on {color: # fff; line-height: 21px; width: 21px; height: 21px; font-size: 16px; margin: 0 1px; border: 0; background-color: # FF7300; font-weight: bold ;}
</Style>
</Head>
<Body>
<Div class = "content">
<Div class = "ad">
<Ul class = "slider">
<Li> </li>
<Li> </li>
<Li> </li>
<Li> </li>
<Li> </li>
</Ul>
<Ul class = "num">
<Li> 1 </li>
<Li> 2 </li>
<Li> 3 </li>
<Li> 4 </li>
<Li> 5 </li>
</Ul>
</Div>
</Div>
</Body>
</Html>
As follows: