Created
October 12, 2012 17:45
-
-
Save fengliu222/3880481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="scroll"> | |
<ul> | |
<li><img src="http://imgsrc.baidu.com/forum/pic/item/ba19c833c895d14316c4f9ad73f0820258af07c8.jpg" alt=""></li> | |
<li><img src="http://imgsrc.baidu.com/forum/pic/item/ba19c833c895d14316c4f9ad73f0820258af07c8.jpg" alt=""></li> | |
<li><img src="http://imgsrc.baidu.com/forum/pic/item/ba19c833c895d14316c4f9ad73f0820258af07c8.jpg" alt=""></li> | |
<li><img src="http://imgsrc.baidu.com/forum/pic/item/ba19c833c895d14316c4f9ad73f0820258af07c8.jpg" alt=""></li> | |
<li><img src="http://imgsrc.baidu.com/forum/pic/item/ba19c833c895d14316c4f9ad73f0820258af07c8.jpg" alt=""></li> | |
</ul> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.moeSlide = function(){ | |
var sUl = $("ul",$(this)); | |
var sLi = $("li",sUl); | |
var speed = 50; | |
//设置UL元素的宽度 | |
sUl.eq(0).css("width",(sLi.length-1)*150+"px"); | |
var timer = setInterval(autoSlide,100); | |
} | |
$.fn.moeSlide.prorotype = { | |
autoSlide:function(){ | |
var pos = paserInt(sUL.position().left); | |
sUl.eq(0).css("left",pos-speed); | |
if(pos>0 $$ pos%150==0){ | |
var ind = pos/150; | |
sLi.eq(0).detach().insertAfter(sUl.eq(0)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.scroll{ | |
width:800px; | |
height:150px; | |
overflow:hidden; | |
postion:relative; | |
} | |
.scroll ul{ | |
width:1200px; | |
position:absolute; | |
left:0;top:0; | |
} | |
.scroll ul li{ | |
list-style:none; | |
float:left; | |
margin:0 5px; | |
} | |
.scroll ul li img{ | |
width:150px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment