Before the picture carousel often use the online plug-in, and then want to say that they also have to look carefully, step by step to understand, so on their own research wrote a picture carousel code, I think it is quite simple. If there is improvement, you are welcome to help me point out the common progress.
(PS: Blog Park How to upload code is available for everyone to download that, has not found a place! )
Html:
<Body><Divclass= "Main"> <Divclass= "MySlide"> <ulclass= "Myslidetwo"> <Li><imgsrc= "Img/dn.jpg"/></Li> <Li> <imgsrc= "Img/ey.jpg"/></Li> <Li><imgsrc= "Img/fxh.jpg"/></Li> <Li><imgsrc= "Img/ss.jpg"/></Li> </ul> <Pclass= "Arrows"> <aclass= "Pre"><</a> <aclass= "Next">></a> </P> <olclass= "Label"> <Liclass= "Current">1</Li> <Li>2</Li> <Li>3</Li> <Li>4</Li> </ol> </Div></Div></Body>
Css:
<style> Body{Background-color:#dddddd; } * {margin:0px;padding:0px;List-style:None; }a{cursor:Pointer; }. Main{position:relative;width:500px;Height:350px;margin:40px Auto; }. MySlide{float: Left;position:Absolute;Overflow:Hidden;width:500px;Height:350px; }. Myslidetwo{position:Absolute;Overflow:Hidden;width:2000px; }. Myslidetwo img{float: Left;width:500px;Height:350px; }. Label{position:Absolute;Bottom:15px; Left:210px;width:200px; }. Label Li{float: Left;width:20px;Height:20px;Line-height:20px;text-align:Center;Margin-right:5px;Border:1px solid #ddd;font-size:14px;background:#fff;cursor:Pointer; }. Label Li.current{background:#0f0; }. Arrows{position:Absolute; Left:0px;Top:120px;Color:#666;font-size:40px;Font-weight:Bold; }. Arrows a{background:Rgba (0,0,0,0.2);Display:Inline-block;width:30px;Height:70px;text-align:Center;Line-height:70px; }. Arrows A:hover{Color:#fff; }. Arrows. Pre{Margin-right:420px; }</style>
Jquey:
<script>$ (document). Ready (function () { var_now=0; varOul = $ (". Myslidetwo"); varNUML = $ (". Label Li"); varWID = $ (". MySlide"). EQ (0). width (); //Digital Icon ImplementationNuml.click (function () { varIndex = $ ( This). index (); $( This). AddClass ("current"). Siblings (). Removeclass (); Oul.animate ({' Left ':-wid * index}, 500); }) //left and RIGHT arrow carousel$ (". Pre"). Click (function () { if(_now>=1) _now--; Else_now=3; Ani (); }); $(". Next"). Click (function () { if(_now = = Numl.size ()-1) {_now= 0; } Else_now++; Ani (); }); //Animation Functions functionani () {numl.eq (_now). addclass ("Current"). Siblings (). Removeclass (); Oul.animate ({' Left ':-wid * _now}, 500); } //The following code if automatic carousel removal is not required //Auto Animation var_interval=setinterval (showtime,2000); functionShowTime () {if(_now = = Numl.size ()-1) {_now= 0; } Else_now++; Ani (); } //Stop the Auto animation when the mouse hovers over the screen and leave the recovery$ (". MySlide"). MouseOver (function() {cleartimeout (_interval); }); $(". MySlide"). Mouseout (function() {_interval=setinterval (showtime,2000); }); });</script>
jquery implements a picture carousel with left and right arrows and digital focus handwriting code