javascript - Sliding li elements -


i'm trying find way make li elements slides. can make them on 1 line (see fiddle) , fit them in ul width. when click on next button want them slide right show hidden li.

my fiddle: http://jsfiddle.net/5cmr7/

smiliar fiddle: http://jsfiddle.net/l5yea/

edit: want this built in better way, , more precise when clicking next.

this need:

jsbin demo

var lin = $('ul.shop-groups li').length; var galw = $('.content').width();     var curr = 0; // set current 'li' slide  function animate(){     var setcurr= (curr===-1) ? (curr = lin-1) : (curr = curr%lin);      $('ul.shop-groups').stop().animate({left: -(galw*curr) },1200);   }  $('#prev, #next').click(function(){   var who= (this.id==='next') ? curr++ : curr-- ;   animate(); }); 

just give id buttons:

<input id="prev" type="button" value="previous"/> <input id="next" type="button" value="next"/> 

and here changed css:

.content {     position:relative; /**/     width:500px;     height:250px;     margin-right:auto;     margin-left:auto;     background-color:#555;      overflow:hidden; /**/ }  ul.shop-groups {     position:absolute; /**/     left:0px;     background-color: #dddddd;     border-bottom: 1px solid #cccccc;     width: 999999px; } ul.shop-groups {     color: #fff;     display: block;     font-size: 1.1em;     font-weight: bold;     line-height: 20px;     min-width: 20px;     padding: 2px 15px;     text-align: center; } li.shop-items {     position:relative;/**/     float:left;/**/     border: solid 1px #d45;     float : left;     background-color:blue;     height:248px;    /**/     width:498px;     /**/ } 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -