抽奖

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>抽奖</title>
    <meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
    <style type="text/css">
        #lp{
            width:600px;
            height:600px;
            background-image: url(plate_06.png);
            margin:0 auto;
            z-index: 9;
        }
        #button{
            background-image: url(plate_04.png);
            background-position: 0 0px;
            z-index: 10;
            position:absolute;
            top:228px;
            left: 594px;;
            width:150px;
            height: 150px;
            cursor: pointer;

        }
        #gl{
            height:592px;
            width:592px;
            background:url('plate_05.png') left top;
            background-repeat: no-repeat;
            background-position: 0 0px;
            margin:0 auto;
            position: absolute;
            top: 8px;
            left: 380px;
            border: solid 1px;


        }
    </style>
</head>
<body>
        <div id="lp">

        </div>
        <div id="button"></div>
        <div id='gl'>
            <img src="plate_03.png" />
        </div>
        <script type="text/javascript">
            var count = 1 ;
            var sz ;
            var stop;
            var sum = 1;
            function countAward(){
                 var award  = [
                     '5M 永久空间',
                     '80M 永久空间',
                     '1G 永久空间',
                     '200M 永久空间',
                     '100M 永久空间',
                     '20M 永久空间',
                     '继续攒人品',
                     '10G 永久空间',
                     '50M 永久空间',
                     '1T 永久空间',
                  ]
                return award[count-1];
            }
            function getRandom(n){
                return Math.floor(Math.random()*n+1)
            }
            function setHeight(){
                var height = -592;
                var gl = document.getElementById('gl');
                gl.style.backgroundPosition = '0'+''+height*count+'px';
                count += 1;
                sum += 1;
                if(count === 11){
                    gl.style.backgroundPosition = '0 0';
                    count = 1;

                }
                if(sum === sz){
                     clearInterval(stop);
                     alert('恭喜您获得'+countAward());
                }

            }
            function moveA(){
               sz = getRandom(20);
               alert(sz);
               stop = setInterval(setHeight,300);
            }
            function init(){
                var btn = document.getElementById( 'button' );
                btn.addEventListener('mouseover',function(){
                      btn.style.backgroundPosition = '0 150px';
                },false);
                btn.addEventListener('mouseout',function(){
                    btn.style.backgroundPosition = '0 0px';
                },false);
                btn.addEventListener('click',moveA,false);
            }
            window.onload = init;
        </script>
</body>
</html>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值