砸金蛋jsp效果--没有后台功能
2015-12-22 10:54
711 查看
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>砸金蛋游戏</title>
<c:set var="ctxresources" value="${pageContext.request.contextPath}/manage"/>
<link type="text/css" rel="stylesheet" href="${ctxresources}/css/bootstrap.min.css">
<script src="${ctxresources}/js/jquery.min.js"></script>
<style>
.egg{width:660px; height:400px; margin:50px auto 20px auto;}
.egg ul li{z-index:999;}
.eggList{padding-top:110px;position:relative;width:660px;}
.eggList li{float:left;background:url(${ctxresources}/images/egg1.png) no-repeat bottom;width:158px;
height:187px;cursor:pointer;position:relative;margin-left:35px; background-size:100%; list-style:none;}
.eggList li span{position:absolute; width:30px; height:60px; left:68px; top:64px; color:#ff0;
font-size:42px; font-weight:bold}
.eggList li.curr{background:url(${ctxresources}/images/egg2.png) no-repeat bottom;cursor:default;z-index:300;background-size:100%; list-style:none;}
.eggList li.curr sup{position:absolute;background:url(${ctxresources}/images/body-bg.png) no-repeat;width:232px;
height:181px;top:-36px;left:-34px;z-index:800;}
.hammer{background:url(${ctxresources}/images/zhuizi.png) no-repeat;width:74px;height:87px;position:absolute;
text-indent:-9999px;z-index:150;left:168px;top:100px;background-size:100%;}
.resultTip{position:absolute; background:#ffc ;width:148px;padding:6px;z-index:500;top:200px;
left:10px; color:#f60; text-align:center;overflow:hidden;display:none;z-index:500;}
.resultTip b{font-size:14px;line-height:24px;}
</style>
<script>
$(function(){
$(".eggList li").hover(function() {
var posL = $(this).position().left + $(this).width();
$("#hammer").show().css('left', posL);
})
$(".eggList li").click(function() {
$(this).children("span").hide();
eggClick($(this));
});
function eggClick(obj) {
var _this = obj;
_this.unbind('click'); //解除click
$(".hammer").css({"top":_this.position().top-55,"left":_this.position().left+185});
$(".hammer").animate({//锤子动画
"top":_this.position().top-25,
"left":_this.position().left+125
},30,function(){
_this.addClass("curr"); //蛋碎效果
_this.find("sup").show(); //金花四溅
$(".hammer").hide();//隐藏锤子
$('.resultTip').css({display:'block',top:'100px',left:_this.position().
left+45,opacity:0})
.animate({top: '50px',opacity:1},300,function(){//中奖结果动画
$("#result").html("中奖结果提示");
//$("#result").html("很遗憾,您没能中奖!");
});
}
);
}
});
</script>
</head>
<body>
<div class="egg">
<ul class="eggList">
<p class="hammer" id="hammer">锤子</p>
<p class="resultTip" id="resultTip"><b id="result"></b></p>
<li><span>1</span><sup></sup></li>
<li><span>2</span><sup></sup></li>
<li><span>3</span><sup></sup></li>
</ul>
</div>
</body>
</html>
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>砸金蛋游戏</title>
<c:set var="ctxresources" value="${pageContext.request.contextPath}/manage"/>
<link type="text/css" rel="stylesheet" href="${ctxresources}/css/bootstrap.min.css">
<script src="${ctxresources}/js/jquery.min.js"></script>
<style>
.egg{width:660px; height:400px; margin:50px auto 20px auto;}
.egg ul li{z-index:999;}
.eggList{padding-top:110px;position:relative;width:660px;}
.eggList li{float:left;background:url(${ctxresources}/images/egg1.png) no-repeat bottom;width:158px;
height:187px;cursor:pointer;position:relative;margin-left:35px; background-size:100%; list-style:none;}
.eggList li span{position:absolute; width:30px; height:60px; left:68px; top:64px; color:#ff0;
font-size:42px; font-weight:bold}
.eggList li.curr{background:url(${ctxresources}/images/egg2.png) no-repeat bottom;cursor:default;z-index:300;background-size:100%; list-style:none;}
.eggList li.curr sup{position:absolute;background:url(${ctxresources}/images/body-bg.png) no-repeat;width:232px;
height:181px;top:-36px;left:-34px;z-index:800;}
.hammer{background:url(${ctxresources}/images/zhuizi.png) no-repeat;width:74px;height:87px;position:absolute;
text-indent:-9999px;z-index:150;left:168px;top:100px;background-size:100%;}
.resultTip{position:absolute; background:#ffc ;width:148px;padding:6px;z-index:500;top:200px;
left:10px; color:#f60; text-align:center;overflow:hidden;display:none;z-index:500;}
.resultTip b{font-size:14px;line-height:24px;}
</style>
<script>
$(function(){
$(".eggList li").hover(function() {
var posL = $(this).position().left + $(this).width();
$("#hammer").show().css('left', posL);
})
$(".eggList li").click(function() {
$(this).children("span").hide();
eggClick($(this));
});
function eggClick(obj) {
var _this = obj;
_this.unbind('click'); //解除click
$(".hammer").css({"top":_this.position().top-55,"left":_this.position().left+185});
$(".hammer").animate({//锤子动画
"top":_this.position().top-25,
"left":_this.position().left+125
},30,function(){
_this.addClass("curr"); //蛋碎效果
_this.find("sup").show(); //金花四溅
$(".hammer").hide();//隐藏锤子
$('.resultTip').css({display:'block',top:'100px',left:_this.position().
left+45,opacity:0})
.animate({top: '50px',opacity:1},300,function(){//中奖结果动画
$("#result").html("中奖结果提示");
//$("#result").html("很遗憾,您没能中奖!");
});
}
);
}
});
</script>
</head>
<body>
<div class="egg">
<ul class="eggList">
<p class="hammer" id="hammer">锤子</p>
<p class="resultTip" id="resultTip"><b id="result"></b></p>
<li><span>1</span><sup></sup></li>
<li><span>2</span><sup></sup></li>
<li><span>3</span><sup></sup></li>
</ul>
</div>
</body>
</html>
相关文章推荐
- JQuery1——基础($对象,选择器,对象转换)
- JavaScript演示排序算法
- 2015-2016网页设计趋势分析 Web Design of Trends
- jQuery Ajax 跨域调用
- 移动端的长按事件
- jquery教程靠边站,一分钱不花让你免费学会jquery
- JQuery+Strusts1.x无刷新登录
- JavaScript 各种遍历方式详解
- jQuery菜单插件用法实例
- JQuery 初体验(建议学习jquery)
- 基于Jquery和CSS3制作数字时钟附源码下载(CSS3篇)
- Jquery实现的table最后一行添加样式的代码
- jQuery实现向下滑出的平滑下拉菜单效果
- jQuery 练习[一] 学习jquery的准备工作
- jquery获得页面元素的坐标值实现思路及代码
- 使用Browserify配合jQuery进行编程的超级指南
- jquery如何实现在加载完iframe的内容后再进行操作
- jquery $.ajax()取xml数据的小问题解决方法
- jQuery '行 4954 错误: 不支持该属性或方法' 的问题解决方法
- Jquery 表单取值赋值的一些基本操作