Chinaunix首页 | 论坛 | 博客
  • 博客访问: 161437
  • 博文数量: 19
  • 博客积分: 470
  • 博客等级: 下士
  • 技术积分: 252
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-06 09:16
文章分类

全部博文(19)

文章存档

2013年(2)

2012年(17)

分类: WINDOWS

2012-06-14 15:48:35



   代码部分:  

点击(此处)折叠或打开

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
  2. <html xmlns="">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>实用的图片切换</title>
  6. <script type="text/javascript" src=""></script>

  7. <style type="text/css">
  8.  body,ul,li { padding:0; margin:0}
  9.  ul,li { list-style:none}
  10.  .img-scroll { position:relative; margin:20px auto; width:440px;}
  11.  .img-scroll .prev,.img-scroll .next { position:absolute; display:block; width:50px; height:100px; background-color:#000;
  12.  top:0; color:#FFF; text-align:center; line-height:100px}
  13.  .img-scroll .prev { left:0;cursor:pointer;}
  14.  .img-scroll .next { right:0;cursor:pointer;}
  15.  .img-list { position:relative; width:320px; height:100px; margin-left:60px; overflow:hidden}
  16.  .img-list ul { width:9999px;}
  17.  .img-list li { float:left; display:inline; width:100px; margin-right:10px; height:100px; background-color:#BDBDDF; text-align:center; line-height:100px;}
  18. </style>
  19. </head>
  20. <body>
  21. <div class="img-scroll">
  22.     <span class="prev">prev</span>
  23.     <span class="next">next</span>
  24.     <div class="img-list">
  25.         <ul>
  26.             <li><img style="width:100px;height:100px;" src="./img/cat.jpg"></li>
  27.             <li><img style="width:100px;height:100px;" src="./img/katong.jpg"></li>
  28.             <li><img style="width:100px;height:100px;" src="./img/meinv.jpg"></li>
  29.             <li><img style="width:100px;height:100px;" src="./img/mm.jpg"></li>
  30.             <li><img style="width:100px;height:100px;" src="./img/慢慢.jpg"></li>
  31.             <li><img style="width:100px;height:100px;" src="./img/美食杰-糖糖.jpg"></li>
  32.             <li><img style="width:100px;height:100px;" src="./img/未命名44.jpg"></li>
  33.         </ul>
  34.     </div>
  35. </div>
  36. <script type="text/javascript">
  37.  function DY_scroll(wraper,prev,next,img,speed,or)
  38.  {
  39.   var wraper = $(wraper);
  40.   var prev = $(prev);
  41.   var next = $(next);
  42.   var img = $(img).find('ul');
  43.   var w = img.find('li').outerWidth(true);
  44.   var s = speed;
  45.   next.click(function()
  46.        {
  47.         img.animate({'margin-left':-w},function()
  48.                   {
  49.                    img.find('li').eq(0).appendTo(img);
  50.                    img.css({'margin-left':0});
  51.                    });
  52.         });
  53.   prev.click(function()
  54.        {
  55.         img.find('li:last').prependTo(img);
  56.         img.css({'margin-left':-w});
  57.         img.animate({'margin-left':0});
  58.         });
  59.   if (or == true)
  60.   {
  61.    ad = setInterval(function() { next.click();},s*1000);
  62.    wraper.hover(function(){clearInterval(ad);},function(){ad = setInterval(function() { next.click();},s*1000);});

  63.   }
  64.  }
  65.  DY_scroll('.img-scroll','.prev','.next','.img-list',3,false);// true为自动播放,不加此参数或false就默认不自动
  66. </script>
  67. </body>
  68. </html>

阅读(35311) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~