简易向左移动的滚动效果 jquery simple marquee
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>简易marquee效果</title> <style type="text/css"> #marquee2{ width:400px; /**超出元素部分隐藏*/ overflow:hidden; background:#EFEFEF; /**定位放在中间主要是为不放到屏幕边缘*/ position: absolute; left:200px; top:150px; } #marquee2 ul{ list-style: none; position: relative; left: auto; top:auto; } #marquee2 ul li{ float:left; padding:0 10px; line-height:25px; } </style> <script src="bower_components/jquery/dist/jquery.js"></script> <script type="application/javascript"> $(document).ready(function () { var marqueeWith = $('#marquee2').width(); var left = $('#marquee2 ul').width(); console.log(left); var animateTime = 5000; //移动到#marquee2宽度结尾的时间 var resetTimeout = 10; //让ul元素在animateTime内向移动marqueeWith像素 $('#marquee2 ul').animate({'left': '-'+(marqueeWith)+'px'},animateTime); setInterval(function(){ console.log('a') //使ul元素在10毫秒内移到父元素div的宽度外 $('#marquee2 ul').animate({'left': marqueeWith +'px'},resetTimeout); setTimeout(function(){ $('#marquee2 ul').animate({'left': '-'+(marqueeWith)+'px'},animateTime); },resetTimeout); },(animateTime+resetTimeout)); }) </script> </head> <body> <div id="marquee2" > <ul> <li>内容1</li> <li>内容2</li> <li>内容3</li> <li>内容4</li> <li><img src="http://ku.shouce.ren/libs/kxbdMarquee/img/02s.jpg" /></li> </ul> </div> </body> </html>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17