快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

纯JS实现轮播图的示例分析-创新互联

这篇文章主要介绍了纯JS实现轮播图的示例分析,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

台儿ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

如下代码:




  
  图片轮播的效果
  
    * {
      margin: 0;
      padding: 0;
      text-decoration: none;
    }
    body {
      padding: 20px;
    }
    #container {
      position: relative;
      width: 600px;
      height: 400px;
      border: 3px solid #333;
      overflow: hidden;
    }
    #list {
      position: absolute;
      z-index: 1;
      width: 4200px;
      height: 400px;
    }
    #list img {
      float: left;
      width: 600px;
      height: 400px;
    }
    #buttons {
      position: absolute;
      left: 250px;
      bottom: 20px;
      z-index: 2;
      height: 10px;
      width: 100px;
    }
    #buttons span {
      float: left;
      margin-right: 5px;
      width: 10px;
      height: 10px;
      border: 1px solid #fff;
      border-radius: 50%;
      background: #333;
      cursor: pointer;
    }
    #buttons .on {
      background: orangered;
    }
    .arrow {
      position: absolute;
      top: 180px;
      z-index: 2;
      display: none;
      width: 40px;
      height: 40px;
      font-size: 36px;
      font-weight: bold;
      line-height: 39px;
      text-align: center;
      color: #fff;
      background-color: RGBA(0, 0, 0, .3);
      cursor: pointer;
    }
    .arrow:hover {
      background-color: RGBA(0, 0, 0, .7);
    }
    #container:hover .arrow {
      display: block;
    }
    #prev {
      left: 20px;
    }
    #next {
      right: 20px;
    }
  



  
    
    
    
    
    
    
    
  
                              
  <   >
  window.onload=function(){     var container = document.getElementById("container");     var list = document.getElementById("list");     var buttons = document.getElementById("buttons").getElementsByTagName('span');     var prev = document.getElementById("prev");     var next = document.getElementById("next");     var index = 1;    function animate(offset){      var newLeft = parseInt(list.style.left) + offset;      list.style.left = newLeft + 'px';      if(newLeft<-3000){        list.style.left= -600 +'px';      }      if(newLeft>-600){        list.style.left = -3000 + 'px';      }    }    function buttonsshow(){      for(var i =0; i5){        index=1;      }      buttonsshow();      animate(-600);    };    //自动播放    var timer;     function play(){       timer= setInterval(function(){         next.onclick();       },1000)     }     play();     function stop(){       clearInterval(timer);     }     container.onmouseover=stop;     container.onmouseout=play; for(var i=0; i

感谢你能够认真阅读完这篇文章,希望小编分享的“纯JS实现轮播图的示例分析”这篇文章对大家有帮助,同时也希望大家多多支持创新互联建站,关注创新互联网站建设公司行业资讯频道,更多相关知识等着你来学习!

另外有需要云服务器可以了解下创新互联建站www.cdcxhl.com,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站题目:纯JS实现轮播图的示例分析-创新互联
文章出自:http://6mz.cn/article/dohssc.html