Today to share the mouse click button, the picture to switch + picture automatic switch + click on the left and right button picture to switch the combination of the three effects of the code.
The final effect is as follows:
HTML code section:
CSS Code section:
*{margin:0px;padding:0px} Li{list-style:none} A{text-decoration:none} img{border:0px }. banner{width:350px;height:495px;margin:100px Auto;position:relative;overflow:hidden}. Banner. pic{width:9999px; HEIGHT:495PX}. Banner. pic Li{width:350px;height:495px;float:left}. Banner. Anniu{width:100px;height:16px;position: absolute;left:165px;top:470px} banner. Anniu li{width:16px;height:16px;background:white;float:left;margin:2px;
Display:inline; cursor:pointer;border-radius:100%}. Banner. Anniu li.on{background:red} banner. lr{width:350px;height:50px; Position:absolute;top:250px;display:none}. Banner. LR a{color:white}. Banner. lr. Pre{width:20px;height:50px;float: Left;background:none repeat scroll 0px 0px rgba (1, 0, 0, 0.6); Text-align:center;line-height:50px;cursor:pointer}. Banner. LR. Next{width:20px;height:50px;float:right;background:none repeat scroll 0px 0px rgba (1, 0, 0, 0.6); Text-align: Center;line-height:50px;cursor:pointer}
JavaScript code section:
$ (function () {//mouse over banner, left and right button to display and hide $ (". Banner"). Hover (function () {$ (. lr). Show ();
},function () {$ (". LR"). Hide ();
});
Click on the small button below, the picture to toggle the effect of $ (". Anniu li"). Click (function () {$ (this). addclass (' on '). Siblings (). Removeclass ("on");
var num=$ (this). index ();
$ (". Pic"). Animate ({Marginleft:-350*num}, "slow");
});
Picture Automatic Carousel effect var a=0;
var automatic=setinterval (function () {a++;
a=a%5;
$ (". Pic"). Animate ({marginleft:-350*a}, "slow");
$ (". Anniu li"). EQ (a). addclass (' on '). Siblings (). Removeclass ("on");
},6000);
Click the left and right button, the picture to toggle the effect of $ (". Pre"). Click (function () {a--;
A= (a+5)%5;
$ (". Pic"). Animate ({marginleft:-350*a}, "slow");
$ (". Anniu li"). EQ (a). addclass (' on '). Siblings (). Removeclass ("on");
});
$ (". Next"). Click (function () {a++;
a=a%5;
$ (". Pic"). Animate ({marginleft:-350*a}, "slow");
$ (". Anniu li"). EQ (a). addclass (' on '). Siblings (). Removeclass ("on");
}); });