zoukankan      html  css  js  c++  java
  • DIV+CSS+javascript 手动轮播图

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>轮播图</title>
    <style type="text/css">
    *{margin:0;padding: 0;}

    #wrap{
    500px;
    height: 360px;
    margin: 100px auto;
    position: relative;
    }
    #pic {
    500px;
    height: 360px;
    position: relative;
    }
    #pic img{
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    }
    #btn div{
    30px;
    height: 50px;
    background: #999;
    cursor: pointer;
    font-size: 18px;
    color: #FFF;
    font-weight: bold;
    font-family: "微软雅黑";
    text-align: center;
    line-height: 50px;
    position: absolute;
    top: 50%;
    margin-top: -25px;

    }
    #left {
    left: 0;

    }
    #right {
    right: 0;

    }


    </style>

    </head>
    <body>

    <div id="wrap">
    <div id="pic">
    <img src="img/1.jpg" style="display: none;"/>
    <img src="img/2.jpg" style="display: none;"/>
    <img src="img/3.jpg" style="display: none;"/>
    <img src="img/4.jpg" style="display: none;"/>
    <img src="img/5.jpg" style="display: none;"/>
    </div>
    <div id="btn">
    <div id="left">&lt;</div>
    <div id="right">&gt;</div>
    </div>
    </div>

    <script type="application/javascript">
    var oImg = document.getElementById('pic').getElementsByTagName('img');
    var oLeft = document.getElementById('left');
    var oRight = document.getElementById('right');
    oImg[0].style.display = 'block';
    var a=0 ;
    oRight.onclick = function(){
    oImg[a].style.display = 'none';
    a++;
    if(a>=oImg.length)
    a=0;
    oImg[a].style.display = 'block';
    }
    oLeft.onclick = function(){
    oImg[a].style.display = 'none';
    a--;
    if(a<0){
    a = oImg.length-1;
    }
    oImg[a].style.display = 'block';
    }

    </script>

    </body>
    </html>

  • 相关阅读:
    基本数据结构:链表(list)
    字符串函数
    TCHAR
    开源库链接
    视频 链接
    tabbar
    加密
    安全类链接,https
    资本
    审核 -链接 - 发布证书
  • 原文地址:https://www.cnblogs.com/jessi/p/5403726.html
Copyright © 2011-2022 走看看