• 图片轮播


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
    .container{
    position: relative;
    }
    .container > img,
    .container .toolbar{
    position: absolute;
    }
    .container > img{
    left: 0;
    top: 0;
    }
    .container .toolbar{
    top: 430px;
    left: 150px;
    z-index: 100;
    }
    .container .toolbar a{
    display: inline-block;
    20px;
    height: 20px;
    background-color: blue;
    color: #ffffff;
    text-align: center;
    line-height: 20px;
    text-decoration: none;

    }
    .container .toolbar a.curr,
    .container .toolbar a:hover{
    background-color: yellow;
    color: #000;
    }
    </style>
    </head>
    <body>
    <div class="container">
    <img src="images/1.jpg" alt=""/>
    <img src="images/2.jpg" alt=""/>
    <img src="images/3.jpg" alt=""/>
    <img src="images/4.jpg" alt=""/>
    <img src="images/5.jpg" alt=""/>
    <img src="images/6.jpg" alt=""/>
    <div class="toolbar">
    <a href="javascript:void(0);" class="curr" onmouseover="showImg(0)" onmouseout="showImg('start')" >1</a>
    <a href="javascript:void(0);" onmouseover="showImg(1)" onmouseout="showImg('start')" >2</a>
    <a href="javascript:void(0);" onmouseover="showImg(2)" onmouseout="showImg('start')" >3</a>
    <a href="javascript:void(0);" onmouseover="showImg(3)" onmouseout="showImg('start')" >4</a>
    <a href="javascript:void(0);" onmouseover="showImg(4)" onmouseout="showImg('start')" >5</a>
    <a href="javascript:void(0);" onmouseover="showImg(5)" onmouseout="showImg('start')" >6</a>
    </div>
    </div>
    </body>

    <script type="text/javascript">

    var interval;
    //当前图片的索引
    var index = 0;
    var imgs = document.querySelectorAll(".container > img");
    var aes = document.querySelectorAll(".container > .toolbar > a");

    function showImg(num){

    if(num){
    if(typeof num == "number" && num>=0 && num<aes.length){
    index = num;
    clearInterval(interval);
    }

    if(num == 'start'){
    interval = setInterval(showImg,2000);
    return ;
    }

    }


    //得到图片
    for(var i=0;i<imgs.length;i++){
    //如果是当前要显示的图片 则设置z-index为最大 否则 设置为数组下标+1
    if(i == index){
    imgs[i].style.zIndex = 99;
    aes[i].className = "curr";
    }else{
    imgs[i].style.zIndex = (i+1);
    aes[i].className = " ";
    }
    }

    if(index > imgs.length-1){
    index = 0;
    }else{
    index++;
    }
    }

    interval = setInterval(showImg,2000);
    showImg();
    </script>
    </html>

  • 相关阅读:
    Ext的组件结构分析(转)
    分析模式 责任模式
    Nhibernate学习起步之manytoone篇(转 明了篇)
    企业开发框架NHibernate和Spring.Net简介3
    企业开发框架NHibernate和Spring.Net简介4
    NHibernate Cascades: the different between all, alldeleteorphans and saveupdate
    XML与数据库
    企业开发框架NHibernate和Spring.Net简介1
    python对函数的理解
    seleniumwebdriver(python) (十五) 鼠标事件
  • 原文地址:https://www.cnblogs.com/hwgok/p/5754904.html
Copyright © 2020-2023  润新知