简单手风琴特效、轮播

<div style="position: relative; width: 100%; height: 500px;overflow:hidden;">
            <div id="1" style="width: 85%; height: 500px; position: absolute; float: left; transition: 0.7s;background-image:url(img/by1.jpg)" οnmοuseοver="bian(1)"></div>
            <div id="2" style="width: 85%; height: 500px; position: absolute; float: left; transition: 0.7s;background-image:url(img/by2.jpg);left:5%;" οnmοuseοver="bian(2)"></div>
            <div id="3" style="width: 85%; height: 500px; position: absolute; float: left; transition: 0.7s;background-image:url(img/by3.jpg);left:10%;" οnmοuseοver="bian(3)"></div>
            <div id="4" style="width: 85%; height: 500px; position: absolute; float: left; transition: 0.7s;background-image:url(img/by4.jpg);left:15%;" οnmοuseοver="bian(4)"></div>
        </div>
<script>
    function bian(n)
    {
        if (n == 1)
        {
            document.getElementById("1").style.left = "";
            document.getElementById("2").style.left = "85%";
            document.getElementById("3").style.left = "90%";
            document.getElementById("4").style.left = "95%";
        }
        if (n == 2) {
            document.getElementById("1").style.left = "";
            document.getElementById("2").style.left = "5%";
            document.getElementById("3").style.left = "90%";
            document.getElementById("4").style.left = "95%";
        }
        if (n == 3) {
            document.getElementById("1").style.left = "";
            document.getElementById("2").style.left = "5%";
            document.getElementById("3").style.left = "10%";
            document.getElementById("4").style.left = "95%";
        }
        if (n == 4) {
            document.getElementById("1").style.left = "";
            document.getElementById("2").style.left = "5%";
            document.getElementById("3").style.left = "10%";
            document.getElementById("4").style.left = "15%";
        }


    }


</script>

 

简单轮播:

<div id="t"  style="background-image:url(img/by1.jpg);width:100%;height:500px;">
        

    </div>
<script>
    var tp = new Array();
    tp[0] = "url(img/by1.jpg)";
    tp[1] = "url(img/by2.jpg)";
    tp[2] = "url(img/by3.jpg)";
    tp[3] = "url(img/by4.jpg)";
    var tt = document.getElementById("t");
    var xb = 0;
    function huan() {
        xb++;
        if (xb == tp.length)
        {
            xb = 0;
        }
        if (xb == 0)
        {
            tt.style.backgroundImage = tp[0];
        }
        if (xb == 1)
        { tt.style.backgroundImage = tp[1];}
        if (xb == 2)
        { tt.style.backgroundImage = tp[2]; }
        if(xb == 3)
        { tt.style.backgroundImage = tp[3]; }

        window.setTimeout("huan()",2000);
    }
    window.setTimeout("huan()",2000);
</script>

 

转载于:https://www.cnblogs.com/wy1992/p/6563835.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值