钱袋子动画(金币飞出,袋子内动态减少,钱袋子摇晃)

news/2025/2/12 8:08:57/

简述

  • 粗略构图,请发挥想象力哦,哈哈哈
  • 触发点击事件时金币飞出,钱袋子摇晃
  • 钱袋子里面的金币总量动态减少

思想

  • 袋子内部动画就是上面波纹水平移动,金币总量垂直移动(transform:translateX||translateY)
  • 钱袋子摇晃就是Z轴上偏移
  • 金币飞出主要是用transition-origin

代码

html

<div id="container"><div class="top"></div><div class="box "><div class="progress"><image src="wave.png" class="wave"> </image><div class="moneyAll"></div></div></div><div class="take_money"><div class="coinreduce "><image src="coin.png" class="coin"> </image></div></div><button onclick="reduceHandler()">立即领取</button></div>

css

 #container{width: 400px;height: 400px;border:1px solid #ebebeb;margin:100px auto;}.box{position: relative;width: 180px;height: 150px;margin-top: 200px;margin-left: 100px;background: #aaa;overflow: hidden;border-bottom-right-radius: 50%;border-bottom-left-radius: 50%;border-top-right-radius: 42%;border-top-left-radius: 48%;}.progress{transition: all 1s;position: relative;transform: translateY(0%);}.wave{position: relative;left: -280px;top:6px;width:460px ;height:20px ;animation: moveRight 4s linear infinite;}@keyframes moveRight{0%{transform:none;}100%{transform: translateX(60%);}}.coin{width:28px ;height:28px ;}.moneyAll{width: 180px ;height:180px;background-image: linear-gradient(0deg, #ffe98f 0%, #ffce00 100%);}.haorooms{position: absolute;top: 0px;left: 0px;}.take_money{height: 40px;width: 40px;left: 178px;top: -180px;position: relative;z-index: -1;}.top{position: absolute;top: 270px;right: 318px;width: 50px;height: 50px;background: #ffce00;z-index: 0;}button{position: relative;top:-52px;left: 244px;background: transparent;width: 100px;height: 30px;margin:20px ;color: white;}.haorooms{animation: clockwise 1.5s linear 1;transform-origin: 160px 20px; }@keyframes clockwise{0%{transform: rotate(0deg);}100%{transform: rotate(103deg);}}.pool{animation: waggle 1.5s linear infinite;}@keyframes waggle{0%,7%{transform: rotateZ(0);}15%{transform: rotateZ(-15deg);}20%{transform: rotateZ(10deg);}25% {transform: rotateZ(-10deg);}30% {transform: rotateZ(6deg);}35% {transform: rotateZ(-4deg);}40%,100% {transform: rotateZ(0);}

JS

 var progressY = document.getElementsByClassName('progress')[0];var coinreduce = document.getElementsByClassName('coinreduce')[0];var box = document.getElementsByClassName('box')[0];var num=0;function reduceHandler(){num+=5;coinreduce.className+=" haorooms";box.classList+=" pool"progressY.style.transform="translateY("+num+"%)";console.log(coinreduce.className);var timer =  setTimeout(function(){coinreduce.className='coinreduce';box.className='box';},1500)setInterval(timer);        //清理定时器,防止内存泄露}

在这里插入图片描述

建议

  • 金币数量的加减等逻辑可以写上
  • 可以加上音乐

http://www.ppmy.cn/news/496763.html

相关文章

Springboot项目多模块打包jar移动到指定目录,docker打jar包构建镜像部署并运行

环境 springboot&#xff1a;2.7.1 jdk&#xff1a;12 前言 最近想着用docker来部署应用&#xff0c;这就意味着&#xff0c;打jar包时&#xff0c;需要指定打包的位置。并且在每次构建时&#xff0c;能够清除掉旧包&#xff0c;存入新包。 步骤 假设你已经有了一个准备部…

springboot模块化父子项目搭建pom 及打包

父项目 父项目 不做任何代码处理&#xff0c;只管理其他模块&#xff0c; 它的父项目继承springboot 它有自己的 用于子模块引用 它的打包方式为pom 它的<> 管理所有公共jar 版本 它的 管理所有公共jar 它的 管理所有模块 <project xmlns"http://maven.apache.…

同放在袋子里

我在外读书工作&#xff0c;有几年很忙、也很荒唐&#xff0c;竟然两三年没有回家过年。&#xff08;因为每年年初四&#xff0c;我就必须出现在湖南&#xff0c;然后行走在列车上和各个车站&#xff0c;一直到年十六十七&#xff0c;天天看着新闻联播干活&#xff0c;有一点指…

三个袋子

&#xff08;文章修改于2020年3月22日23点45分&#xff09; 第二次做这个原题时WA了两次&#xff0c;才发现是有些隐蔽的数据不能通过&#xff08;如32532525 99999&#xff09;为防止溢出&#xff0c;将所有的int型改为long long int型 时间限制: 1 Sec 内存限制: 128 MB [提交…

【转】手机怎么放可以减少辐射?

文章来源> http://health.huanqiu.com/hygiene/hint/2009-05/466422.html 随着无线通讯技术的发展&#xff0c;使用手机的人越来越多&#xff0c;而手机带来的相关健康问题也引起了人们更多的关注。手机的辐射到底对人体有多大危害&#xff0c;如何把危害的程度降到最低&a…

不要把自己装在袋子里面

这几天一直在处理疾控和卫生监督所网络的事情&#xff0c;感受如下&#xff1a; 1、不要把自己装在袋子里面。 2、不要把喜怒写在脸上。 3、低调是一种实用技巧。 4、有时候留白很重要。 呵呵&#xff0c;就这样吧。

Docker 将jar包 打包成容器,并挂载jar包和指定yml配置

1.在 Dockerfile 中指定基础镜像&#xff0c;如 openjdk:8-jdk-alpine。 2.在 Dockerfile 中创建一个工作目录&#xff0c;如 /app。 3.将 jar 包复制到工作目录中&#xff0c;可以使用 COPY 指令。 4.将 yml 配置文件复制到工作目录中&#xff0c;也可以使用 COPY 指令。 5.暴…

手机放哪里辐射危害最低?

一般来说&#xff0c;手机待机时辐射较小&#xff0c;通话时辐射大一些&#xff0c;而在手机号码已经拨出而尚未接通时&#xff0c;辐射最大&#xff0c;辐射量是待机时的3倍左右。这些辐射有可能改变人体组织&#xff0c;对人体健康造成不利影响。 别放枕头边 据中国室内装…