• 图片轮播


    head里

    <style>
    *{ margin:50px auto;}
    #tuijian{ width:760px;
    height:350px;
    background-repeat:no-repeat;
    background-position:center center;}
    .pages{ top:200px;
    background-color:black;
    opacity:0.5;
    width:30px;
    height:60px;}
    #p1{ float:left;
    margin-left:10px;
    margin-top:150px;}
    #p2{ float:right;
    margin-right:10px;
    margin-top:150px;}
    
    </style>

    body里

    <div id="tuijian" style="background-image:url(1.jpg);">
    <div class="pages" id="p1" onclick="dod(-1)"></div>
    <div class="pages" id="p2" onclick="dod(1)"></div>
    </div>

    html外

    <script>
    var jpg=new Array();
    jpg[0]="url(1.jpg)";
    jpg[1]="url(2.jpg)";
    jpg[2]="url(3.jpg)";
    var tjimg=document.getElementById("tuijian");
    var xb=0;
    var n=0;
    function huan()
    {
        xb++;
        if(xb==jpg.length)
        {
        xb=0;
        }    
        tjimg.style.backgroundImage=jpg[xb];
        if(n==0)
        {
        window.setTimeout("huan()",3000);    
        }
    }
    window.setTimeout("huan()",3000);
    function dod(m)
    {
    
        xb=xb+m;
        if(xb<0)
        {
        xb=jpg.length-1;    
        }
        else if(xb>=jpg.length)
        {
        xb=0;    
        }
        tjimg.style.backgroundImage=jpg[xb];
    }
    
    
    
    </script>

  • 相关阅读:
    java-5
    java-4
    java-03
    java-02
    Java的集合类
    数据库之约束
    网络编程
    多表查询
    二维数组打印乘法表,三角形,输入三个数,输出最大值
    例:进店买衣服案例
  • 原文地址:https://www.cnblogs.com/wy1992/p/6023210.html
Copyright © 2020-2023  润新知