• 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>

  • 相关阅读:
    Mac下安装svn服务器
    php 当前日期加一天和指定日期加一天
    MariaDB与MySQL
    JS中判断null、undefined与NaN的方法
    PHP保留两位小数的几种方法
    jquery的cookie插件
    mysql(5.7以上)查询报错:ORDER BY clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by
    MySQL数据的导出和导入
    qrCode二维码字符串长度太多压缩的问题
    解决 img 标签上下出现的间隙
  • 原文地址:https://www.cnblogs.com/HUANGRONG888/p/6055769.html
Copyright © 2020-2023  润新知