zoukankan      html  css  js  c++  java
  • 图片点击轮播(四)高级--2017-04-05

     点击下方图片轮播:

    关键点:onmouseover ,onmouseout两个事件;DOM;

    <style>
    #datu
    {
    400px;
    height:300px;
    position:relative;
    margin:20px auto;
    overflow:hidden;
    }
    #ta
    {
    position:relative;
    left:0px;
    top:0px;
    transition:0.7s;}
    #suo
    {
    300px;
    height:30px;
    position:relative;
    margin:20px auto;
    border:0px solid blue;
    line-height:30px;}
    .suo
    {
    30px;
    height:30px;
    position:relative;
    border:1px solid yellow;
    float:left;
    margin-left:10px;
    margin-top:10px;}
    </style>
    </head>

    <body>
    <div id="datu" onmouseover="Zhi()" onmouseout="Li()" >
    <table id="ta" cellpadding="0" cellspacing="0">
    <tr height="300">
    <td><img src="turn-pic/a.jpg" width="400" height="300"/></td>
    <td><img src="turn-pic/b.jpg" width="400" height="300" /></td>
    <td><img src="turn-pic/c.jpg" width="400" height="300" /></td>
    <td><img src="turn-pic/d.jpg" width="400" height="300"/></td>
    <td><img src="turn-pic/e.jpg" width="400" height="300"/></td>
    </tr>
    </table>
    </div>
    <div id="suo" onmouseover="Zhi()" onmouseout="Li()">
    <div class="suo" biao="1"><img src="turn-pic/a.jpg" width="30" height="30" /></div>
    <div class="suo" biao="2"><img src="turn-pic/b.jpg" width="30" height="30" /></div>
    <div class="suo" biao="3"><img src="turn-pic/c.jpg" width="30" height="30" /></div>
    <div class="suo" biao="4"><img src="turn-pic/d.jpg" width="30" height="30" /></div>
    <div class="suo" biao="5"><img src="turn-pic/e.jpg" width="30" height="30" /></div>
    </div>
    </body>
    </html>
    <script>
    document.getElementById("ta").style.left="0px";
    document.getElementsByClassName("suo").item(0).style.borderColor="red";

    var biaosuo=1;
    var suo=document.getElementsByClassName("suo");
    for(var i=0;i<suo.length;i++)
    {
    suo.item(i).onclick=function(){
    var biao = this.getAttribute("biao");
    for(var i = 0;i<5;i++)
    {
    if(i==biao-1)
    {
    document.getElementsByClassName("suo").item(i).style.borderColor="red";
    }
    else
    {
    document.getElementsByClassName("suo").item(i).style.borderColor="yellow";
    }
    if(biao==1)
    {
    document.getElementById("ta").style.left="0px";
    }
    else if(biao==2)
    {
    document.getElementById("ta").style.left="-400px";
    }
    else if(biao==3)
    {
    document.getElementById("ta").style.left="-800px";
    }
    else if(biao==4)
    {
    document.getElementById("ta").style.left="-1200px";
    }
    else
    {
    document.getElementById("ta").style.left="-1600px";
    }
    }
    }
    }

    function Change()
    {
    var ta = parseInt(document.getElementById("ta").style.left);
    if(ta>-1600)
    {
    document.getElementById("ta").style.left=(ta-400)+"px";
    ta=ta-400;
    if(ta==-400)
    {
    biaosuo=2;
    }
    else if(ta==-800)
    {
    biaosuo=3;
    }
    else if(ta==-1200)
    {
    biaosuo=4;
    }
    else if(ta=-1600)
    {
    biaosuo=5;
    }
    }
    else
    {
    document.getElementById("ta").style.left="0px";
    biaosuo=1;
    }
    for(var i = 0;i<5;i++)//offsetLeft
    {
    if(i==biaosuo-1)
    {
    document.getElementsByClassName("suo").item(i).style.borderColor="red";
    }
    else
    {
    document.getElementsByClassName("suo").item(i).style.borderColor="yellow";
    }
    }
    shi=window.setTimeout("Change()",3000);
    }
    var shi =window.setTimeout("Change()",3000);
    function Zhi()
    {
    window.clearTimeout(shi);
    }
    function Li()
    {
    shi=window.setTimeout("Change()",1000);
    }
    </script>

  • 相关阅读:
    个人冲刺二(7)
    个人冲刺二(6)
    个人冲刺二(5)
    个人冲刺二(4)
    对称二叉树 · symmetric binary tree
    108 Convert Sorted Array to Binary Search Tree数组变成高度平衡的二叉树
    530.Minimum Absolute Difference in BST 二叉搜索树中的最小差的绝对值
    pp 集成工程师 mism师兄问一问
    17. Merge Two Binary Trees 融合二叉树
    270. Closest Binary Search Tree Value 二叉搜索树中,距离目标值最近的节点
  • 原文地址:https://www.cnblogs.com/chenguanai/p/6670418.html
Copyright © 2011-2022 走看看