jqueryrotate积分抽奖效果演示代码

发布时间: 编辑:WANG 0人评论 3305次浏览 jQuery动画效果插件
jqueryrotate积分抽奖效果演示代码
文件大小:36KB 文件版本:1.0 支持语言:简体中文 网友评分: 3分
更新日期:2023-11-07 下载次数:9 来自:未知

软件介绍

简介:jqueryrotate积分抽奖效果演示代码

jqueryrotate积分抽奖效果演示图片预览

jqueryrotate积分抽奖效果演示图片预览

jqueryrotate积分抽奖效果演示浏览器适配

  • 支持Chrome所有版本
  • 支持Firefox所有版本
  • 支持Safari所有版本
  • 支持IE8及以上版本

jQuery插件浏览器支持

jqueryrotate积分抽奖效果部分代码

1、引入文件

<script src="js/jquery-1.8.3.min.js"></script>
<script src="js/jquery.rotate.min.js"></script>

2、HTML

<div id="chromecj">
    <div class="plate">
        <a id="plateBtn" href="javascript:" title="开始抽奖">开始抽奖</a>
    </div>
 
    <div class="prize">
        <h4>奖品设置</h4>
        <ul>
            <li><strong>一等奖:</strong>iPhone 6 Plus(1名)</li>
            <li><strong>二等奖:</strong>iPhone 6(2名)</li>
            <li><strong>三等奖:</strong>iPad Air 2(5名)</li>
            <li><strong>参与奖:</strong>充电宝(20名)</li>
        </ul>
    </div>
 
    <div id="result">
        <p id="resultTxt"></p>
        <a id="resultBtn" href="javascript:" title="关闭">关闭</a>
    </div>
</div>

3、CSS

#chromecj{
    position: relative;
    width: 780px;
    height: 390px;
    margin: 0 auto;
    padding: 20px;
    border: 1px solid #ddd;
    background: url(images/ly-plate-c.gif) 20px 20px no-repeat;
}
.plate {
    position: relative;
    float: left;
    width: 390px;
    height: 390px;
    background-image: url(images/lyplate.png);
}
.prize {
    float: right;
    width: 360px;
    height: 390px;
    font: 14px/1.5 "Microsoft Yahei";
}
.prize h4 {
    margin: 80px 0 20px;
    padding: 10px;
    background-color: #eee;
}
.prize ul {
    list-style-type: none;
}
.prize li {
    margin: 10px;
}
#plateBtn {
    position: absolute;
    left: 88px;
    top: 88px;
    width: 214px;
    height: 214px;
    background-image: url(images/rotate-static.png);
    text-indent: -9999px;
    overflow: hidden;
}
#result {
    display: none;
    position: absolute;
    left: 65px;
    top: 155px;
    width: 300px;
    height: 120px;
    background-color: rgba(0,0,0,0.75);
    filter: alpha(opacity=90);
}
#resultTxt {
    padding: 45px 15px 0;
    font: 16px "Microsoft Yahei";
    color: #fff;
    text-align: center;
}
#resultTxt em {
    color: #ffea76;
    font-style: normal;
}
#resultBtn {
    position: absolute;
    right: 5px;
    top: 5px;
    width: 25px;
    height: 25px;
    text-indent: -100px;
    background-image: url(images/close.png);
    overflow: hidden;
}

4、JavaScript

$(function(){
    var $plateBtn = $('#plateBtn');
    var $result = $('#result');
    var $resultTxt = $('#resultTxt');
    var $resultBtn = $('#resultBtn');
 
    $plateBtn.click(function(){
        var data = [0, 1, 2, 3, 4, 5, 6, 7];
        data = data[Math.floor(Math.random()*data.length)];
        switch(data){
            case 1: 
                rotateFunc(1,157,'恭喜你中了 <em>一等奖</em>');
                break;
            case 2: 
                rotateFunc(2,65,'恭喜你中了 <em>二等奖</em>');
                break;
            case 3: 
                rotateFunc(3,335,'恭喜你中了 <em>三等奖</em>');
                break;
            case 4: 
                rotateFunc(4,247,'恭喜你中了 <em>四等奖</em>');
                break;
            case 5: 
                rotateFunc(5,114,'谢谢参与,请再接再厉');
                break;
            case 6: 
                rotateFunc(6,24,'谢谢参与,请再接再厉');
                break;
            case 7: 
                rotateFunc(7,292,'谢谢参与,请再接再厉');
                break;
            default:
                rotateFunc(0,203,'恭喜你中了 <em>参与奖</em>');
        }
    });
 
    var rotateFunc = function(awards,angle,text){  //awards:奖项,angle:奖项对应的角度
        $plateBtn.stopRotate();
        $plateBtn.rotate({
            angle: 0,
            duration: 5000,
            animateTo: angle + 1440,  //angle是图片上各奖项对应的角度,1440是让指针固定旋转4圈
            callback: function(){
                $resultTxt.html(text);
                $result.show();
            }
        });
    };
 
    $resultBtn.click(function(){
        $result.hide();
    });
}); 

查看更多

下载地址

下载地址一

转载必须注明来自:https://huajiakeji.com/jquerydonghua/4744.html

评论:(0)

已有 0 位网友发表了一针见血的评论,你还等什么?



为打击盗链困扰,本站已启用公众号人机验证
微信扫码关注公众号,发送"插件"二字获得验证码,验证码5分钟有效。

Chrome插件离线安装方法