RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
纯JS实现轮播图的示例分析

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

成都创新互联公司专注于阳东企业网站建设,自适应网站建设,商城开发。阳东网站建设公司,为阳东等地区提供建站服务。全流程定制制作,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务

如下代码:




  
  图片轮播的效果
  
    * {
      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实现轮播图的示例分析”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!


网页题目:纯JS实现轮播图的示例分析
地址分享:http://sczitong.cn/article/pcscje.html