刮刮乐,前端代码html+js实现,直接运行

1,介绍

刮刮乐实现,主要使用jquery.eraser.js实现擦除  在线预览 

效果图如下:

2,代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection">
		<meta content="email=no" name="format-detection">
		<meta name="full-screen" content="yes">
		<meta name="browsermode" content="application">
		<meta name="full-screen" content="yes">
		<meta name="browsermode" content="application">
		<meta name="x5-orientation" content="portrait">
		<title>刮刮乐</title>
		<link rel="stylesheet" href="./index.css">
	</head>

	<style>
		html,
		body {
			margin: 0;
			padding: 0;
			height: 100%;
			width: 100%;
			overflow: hidden;
			background-image: url(ggbj.jpg);
		}
		
		#app {
			position: relative;
			top: 50%; /*偏移*/
			transform: translateY(-50%);
		}
		
		.title {
			color: #ffe519;
			padding-top: 20%;
		}
	
		.outBox {
			height: 500px;
			background-color: #ab0000;
			text-align: center;
			position: relative;
		}

		#scratch {
			position: relative;
			top: 45%;
			width: 200px;
			height: 70px;
			background: #AB945E;
			z-index: 100;
			margin: auto;
		}

		#card {
			width: 100%;
			height: 100%;
			font-size: 28px;
			line-height: 70px;
			color: #ff0000;
			text-align: center;
		}

		.guaguaImg {
			position: absolute;
			top: 0;
			left: 0;
			z-index: 10;
			width: 100%;
			height: 100%;
		}
	</style>


	<body>
		<div id="app" v-show="visible">
			<el-row type="flex" justify="space-around">
			  <el-col :span="4" v-for="(index) in 5">
				 <div class="outBox">
					<h1 class="title">惊喜刮刮乐</h1>
					<div id="scratch">
						<div id="card">{{prizeList[index]}}</div>
						<img class="guaguaImg" :id="ki(index)" src="./guagua.jpg">
					</div>
				  </div>
			  </el-col>
			</el-row>
		</div>

		<script src="./vue.js"></script>
		<script src="./index.js"></script>
		<script src="./jquery-2.1.0.min.js"></script>
		<script src="./jquery.eraser.js"></script>
		<script>
			new Vue({
			  el: '#app',
			  data: function() {
				return { 
					visible: false,
					prizeList: ["上班免打卡", "男票一枚", "谢谢参与", "女票一枚", "带薪休假", "一百万"]
				}
			  },
			  mounted() {
				for(var i = 1; i < 6; i++) {
					this.initCard(i);
				}
			  },
			  created() {
				this.visible = true;
			  },
			  methods: {
				  ki: function (i) {
					  return "guaguaImg" + i
				  },
				  initCard(index) {
					$("#guaguaImg" + index).eraser({
						"size": 15,
						completeRatio: .4, //擦到百分之多少清屏
						completeFunction: function() {
							$("#guaguaImg" + index).eraser('clear');
						}
					});
				  }
			  }
			})
		</script>
	</body>
</html>

3,源代码下载

        需要完整代码请留言或者联系我微信:1171053128

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

左本Web3D

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值