Realization of the left and right seamless carousel diagram

Source: Internet
Author: User

Seamless Carousel Diagram:

<title> Seamless carousel Map </title><style>*{margin:0;padding:0;} Ul{list-style:none;}. banner{width:600px;height:300px;border:2px solid #ccc; margin:100px Auto;position:relative;overflow:hidden;}. Img{position:absolute;top:0;left:0}.img Li{float:left;}. num{position:absolute;bottom:10px;width:100%;text-align:center;font-size:0;}. Num Li{width:10px;height:10px;background:rgba (0,0,0,0.5);d isplay:block;border-radius:100%;d Isplay:inline-block; Margin:0 5px;cursor:pointer;}. Btn{display:none;}. BTN Span{display:block;width:50px;height:100px;background:rgba (0,0,0,0.6); color: #fff; font-size:40px;line-height : 100px;text-align:center;cursor:pointer;}. btn. Prev{position:absolute;left:0;top:50%;margin-top: -50px;}. btn. Next{position:absolute;right:0;top:50%;margin-top: -50px;}. Num. Active{background-color: #fff;} </style><script src= "Http://apps.bdimg.com/libs/jquery/1.8.3/jquery.min.js" ></script></ Head><body><div class= "banner" >&Lt;ul class= "img" ><li><a href= "#" ></a></li>< Li><a href= "#" ></a></li><li><a href= "#" > </a></li><li><a href= "#" ></a></li><li><a href= "#" ></a> </li></ul><ul class= "num" ></ul>//<div class= "btn" ><span class= "prev" ><< /span><span class= "Next" >></span></div></div><script>$ (function () {var i=0; var timer=null;for (var j = 0; J < $ ('. img li '). Length; J + +) {//Create dot $ ('. Num '). Append (' <li></li> ')}$ ('. Nu  M Li '). First (). addclass (' active '); Add a style var firstimg=$ ('. img Li ') to the first dot.  Copy the first picture $ ('. img '). Append (firstimg). Width ($ ('. img li '). length* ($ ('. IMG img '). width ()); After placing the first picture in the last picture, set the ULWidth is the number of pictures * picture width//Next button $ ('. Next '). Click (function () {i++;if ('. img li ') (i==$) {i=1;//This is not i=0$ ('. img '). CSS ({left  : 0}); Guaranteed Seamless Carousel, set left value};$ ('. img '). Stop (). Animate ({left:-i*600},300); if (i==$ ('. img li '). length-1) {//Set small dot indicates $ ('. Num li ') . EQ (0). addclass (' active '). Siblings (). Removeclass (' active ');} else{$ ('. Num li '). EQ (i). addclass (' active '). Siblings (). Removeclass (' active ');}}) Previous button $ ('. Prev '). Click (function () {i--;if (i==-1) {i=$ ('. img li ').. css ({left length-2;$ $ ('. img Li '). length-1) *600});} $ ('. img '). Stop (). Animate ({left:-i*600},300); $ ('. Num li '). EQ (i). addclass (' active '). Siblings (). Removeclass (' Active ');}) Sets the button's display and hides $ ('. Banner '). Hover (function () {$ ('. Btn '). Show ();},function () {$ ('. Btn '). Hide ();}) The mouse is drawn into the dot $ ('. Num li '). MouseOver (function () {var _index=$ (this). index (); $ ('. img '). Stop (). Animate ({left:-_index*600} $ ('. Num li '). EQ (_index). addclass (' active '). Siblings (). Removeclass (' active ');}) Timer AutoPlay timer=setinterval (function () {i++;if ('. img li ') (i==$ (') ') {I=1; $ ('. img '). css({left:0}); $ ('. img '). Stop (). Animate ({left:-i*600},300), if (i==$ ('. img li '). length-1) {$ ('. Num li '). EQ (0). addclass (' active '). Siblings (). Removeclass (' active ');} else{$ ('. Num li '). EQ (i). addclass (' active '). Siblings (). Removeclass (' active '),}},1000)//mouse over, pause AutoPlay, move out, start auto play $ ('. Banner '). Hover (function () {clearinterval (timer);},function () {Timer=setinterval (function () {i++;if (i==$ ('. img Li ') . length) {i=1; $ ('. img '). CSS ({left:0});}; $ ('. img '). Stop (). Animate ({left:-i*600},300), if (i==$ ('. img li '). length-1) {$ ('. Num li '). EQ (0). addclass (' active '). Siblings (). Removeclass (' active ');} else{$ ('. Num li '). EQ (i). addclass (' active '). Siblings (). Removeclass (' active ');}},1000)}) </script>

  

Realization of the left and right seamless carousel diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.