zoukankan      html  css  js  c++  java
  • js小效果-轮播图

    <!DOCTYPE html>
    <html>
    <head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
    *{
    margin: 0;
    padding: 0;
    list-style: none;
    }
    #wrap{
    500px;
    height:260px;
    margin:50px auto;
    position:relative;
    overflow: hidden;
    border: 1px solid #000;
    }
    #wrap a {
    30px;
    height:30px;
    line-height:30px;
    background: red;
    opacity: 0.3;
    display: block;
    text-align: center;
    z-index:990;
    position: absolute;
    text-decoration: none;
    }
    #prev{left:0;
    top:110px;
    }
    #next{right:0;
    top:110px;}
    #box li{
    500px;
    height:260px;
    }
    #box{
    position: absolute;
    height:1300px;
    }
    img{
    500px;
    height:260px;
    }
    #btn{
    position: absolute;
    bottom:10px;
    text-align: center;
    margin-left: 175px;
    z-index: 999;
    }
    #btn li{
    20px;
    height:20px;
    border-radius: 20px;
    background: #ccc;
    margin-left: 5px;
    float:left;
    }
    #wrap #btn li.active{background:mediumvioletred;}
    </style>
    <script src="move1.js"></script>
    <script>
    window.onload=function(){
    var oWrap=document.getElementById('wrap');
    var oPrev=document.getElementById('prev');
    var oNext=document.getElementById('next');
    var oBox=document.getElementById('box');
    var aLi=oBox.children;
    var oBtn=document.getElementById('btn');
    var aBtn=oBtn.children;
    var iNow=0;
    for(var i=0;i<aBtn.length;i++){
    aBtn[i].index=i;
    aBtn[i].onclick=function(){
    iNow=this.index;
    tab();
    }
    };
    function tab(){
    for(var i=0;i<aBtn.length;i++){
    aBtn[i].className='';
    }
    aBtn[iNow].className='active';
    move(oBox,{top:-aLi[0].offsetHeight*iNow},{time:1000,easing:'ease-in'});
    };
    oPrev.onclick=function(){
    iNow--;
    if(iNow==-1)iNow=aBtn.length-1;
    tab();
    };
    oNext.onclick=next;
    function next() {
    iNow++;
    if (iNow == aBtn.length)iNow = 0;
    tab();
    };
    var timer=null;
    timer=setInterval(next,2000);
    oWrap.onmouseover=function(){
    clearInterval(timer) ;
    };
    oWrap.onmouseout=function(){
    timer=setInterval(next,2000);
    };
    }
    </script>
    </head>
    <body>
    <div id="wrap">
    <a href="javascript:;" id="prev">←</a>
    <a href="javascript:;" id="next">→</a>
    <ul id="box">
    <li><img src="img/b1.jpg" alt=""/></li>
    <li><img src="img/b2.jpg" alt=""/></li>
    <li><img src="img/b3.jpg" alt=""/></li>
    <li><img src="img/b4.jpg" alt=""/></li>
    <li><img src="img/b5.jpg" alt =""/></li>
    </ul>
    <ol id="btn">
    <li class="active"></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    </ol>
    </div>
    </body>
    </html>

  • 相关阅读:
    PHP数组内容不重复组合排列算法
    【转】五种常见的 PHP 设计模式
    【转】PHP ob_start() 函数介绍
    【转】apache/php 开启 gzip压缩
    【转】HTTP 头部解释,HTTP 头部详细分析,最全HTTP头部信息
    【转】MySQL数据库MyISAM和InnoDB存储引擎的比较
    【转】PHP 位运算应用口诀
    require,include,require_once,include_once的区别
    Linux下Redis安装使用,主从模式,哨兵模式与PHP扩展(PHP7适用)
    php-fpm启动,重启,终止操作
  • 原文地址:https://www.cnblogs.com/HUANGRONG888/p/6055769.html
Copyright © 2011-2022 走看看