怎么实现js焦点轮播效果

这篇文章将为大家详细讲解有关怎么实现js焦点轮播效果,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

网站建设哪家好,找成都创新互联公司!专注于网页设计、网站建设、微信开发、微信小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了泰顺免费建站欢迎大家使用!

实现代码:




  
  
  
    *{
      margin: 0;
      padding: 0;
      list-style: none;
      text-decoration: none;
    }
    .wrap{
      width: 490px;
      height: 170px;
      margin: 100px auto;
      border: 1px solid #000000;
      position: relative;
      overflow: hidden;
    }
    #pic{
      width: 3430px;
      position: absolute;
    }
    #pic li{
      float: left;
      height: 170px;
    }
    #list{
      position: absolute;
      bottom: 10px;
      left:150px ;
    }
    #list li{
      float: left;
      width: 15px;
      height: 15px;
      background: #fff;
      margin: 0 10px;
      border-radius: 50%;
      cursor: pointer;
    }
    #list .on{
      background: #e27a00;
    }
    .Prev{
      top: 30px;
      left: 0;
    }
    .Next{
      top: 30px;
      right: 0;
    }
    .Prev,.Next{
      position: absolute;
      font-size: 80px;
      font-weight: bold;
      color:#fff ;
      -webkit-transition: all 0.35s ease-in-out
    }
    .Next:hover,
    .Prev:hover{
      background: #ccc;
      background: rgba(204, 204, 204, 0.4);
    }

  
  
    window.onload=function(){
      var wrap=document.getElementById('wrap');
      var pic=document.getElementById('pic');
      var Li=document.getElementById('list').getElementsByTagName('li');
      var prev=document.getElementById('Prev');
      var next=document.getElementById('Next');
      var animated=false;
      var index=0;
      var timer=null;
      next.onclick=function(){
        if(animated){//如果图片正在滚动时要返回,否则index会变化
          return;
        }
        else{
          index++;
          if(index>=Li.length){
            index=0;
          }
        }

        showlist();
        if(animated == false){//if(!animated)
          animate(-490);
        }
      }
      prev.onclick=function(){
        if(animated){
          return;
        }
        else{
          index--;
          if(index<=0){
            index=Li.length-1;
          }
        }

        showlist();
        if(!animated){//判断其是否滚动完
          animate(490);
        }
      }
      for(var i=0;i newLeft )|| (speed > 0 && parseInt(pic.style.left) < newLeft)){
            pic.style.left = parseInt(pic.style.left) + speed + 'px';
            setTimeout(go,interval);
          }else{
            animated=false;
            pic.style.left= newLeft + 'px';
            if(newLeft > -490){
              pic.style.left = -2450 + 'px';
            }
            if(newLeft < -2450){
              pic.style.left = -490 + 'px';
            }
          }
        }
        go();
      }
      //圆点变换
      function showlist(){
        for(var i=0;i



  
    
  •     
  •     
  •     
  •     
  •     
  •     
  •                
  •     
  •     
  •     
  •      <   >

    关于“怎么实现js焦点轮播效果”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。


    本文名称:怎么实现js焦点轮播效果
    URL链接:http://csdahua.cn/article/ighhss.html
    扫二维码与项目经理沟通

    我们在微信上24小时期待你的声音

    解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流