图片轮播图_点击左右按钮切换_轮播自由控制效果jq实现

管理员 发布于 6年前   373
        <style type="text/css">
         .img-scroll { position:relative; margin:20px auto; width:100%;}
         .img-scroll .prev,.img-scroll .next { position:absolute;top: 200px;color: #999;font-size: 60px;}
         .img-scroll .prev { left:0;cursor:pointer;}
         .img-scroll .next { right:0;cursor:pointer;}
         .img-list { position:relative; width:320px;height: 635px; margin-left:75px; overflow:hidden}
         .img-list ul { width:100%;}
         .img-list li { float:left; display:inline; width:100%;height:100%; margin-right:10px; background-color:#BDBDDF; text-align:center;}
        </style>
        <div class="img-scroll">
            <span class="prev"><</span>
            <span class="next">></span>
            <div class="img-list">
                <ul>
                    <li><img style="width:100%;" src="images/005-1.png"></li>
                    <li><img style="width:100%;" src="images/005-2.png"></li>
                    <li><img style="width:100%;" src="images/005-3.png"></li>
                    <li><img style="width:100%;" src="images/005-4.png"></li>
                </ul>
            </div>
        </div>
        <script type="text/javascript">
             function DY_scroll(wraper,prev,next,img,speed,or)
             { 
                  var wraper = $(wraper);
                  var prev = $(prev);
                  var next = $(next);
                  var img = $(img).find('ul');
                  var w = img.find('li').outerWidth(true);
                  var s = speed; 
                  next.click(function() 
                       { 
                        img.animate({'margin-left':-w},function() 
                                  { 
                                   img.find('li').eq(0).appendTo(img); 
                                   img.css({'margin-left':0}); 
                                   });
                        });
                  prev.click(function()
                       {
                        img.find('li:last').prependTo(img);
                        img.css({'margin-left':-w}); 
                        img.animate({'margin-left':0});
                        });
                  if (or == true)
                  {
                   ad = setInterval(function() { next.click();},s*1000);
                   wraper.hover(function(){clearInterval(ad);},function(){ad = setInterval(function() { next.click();},s*1000);});
                  }
             }
             DY_scroll('.img-scroll','.prev','.next','.img-list',3,false);// true为自动播放,不加此参数或false就默认不自动
        </script>

效果图就不贴了 需要的自己试试 改改就能用

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

该博客于2020-12-7日,后端基于go语言的beego框架开发
前端页面使用Bootstrap可视化布局系统自动生成

是我仿的原来我的TP5框架写的博客,比较粗糙,底下是入口
侯体宗的博客

      订阅博客周刊

文章标签

友情链接

HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群
侯体宗的博客