react实现时钟翻牌效果

devtools/2024/10/18 8:24:25/

需求:随着数字的变动要求有时钟翻动动效

问题:只在加载时有动效

解决方案:通过判断数字改变(这里通过新旧数值变动来判断,不贴代码啦),每次变动的时候手动把animationIterationCount设置为infinite(持续动画),半秒后改为1(动画只执行一次),

特效参考代码

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>数字翻牌效果</title><style>body {margin: 0 auto;padding: 0;text-align: center;}.container {position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);width: 908px;height: 150px;background-color: #cc3131;border-bottom: 5px solid #ff8b8b;border-radius: 12px;}.item {position: relative;margin: 8px 5px 0;display: inline-block;width: 72px;height: 130px;/*background-color: #fe4e4e;*/background: -webkit-linear-gradient(#a42121, #fe4e4e, #bd2a2a); /* Safari 5.1 - 6.0 */background: -o-linear-gradient(#a42121, #fe4e4e, #bd2a2a); /* Opera 11.1 - 12.0 */background: -moz-linear-gradient(#a42121, #fe4e4e, #bd2a2a); /* Firefox 3.6 - 15 */background: linear-gradient(#a42121, #fe4e4e, #bd2a2a); /* 标准的语法 */border-radius: 12px;}.under, .on {position: absolute;left: 0;top: 0;width: 100%;height: 100%;line-height: 130px;color: #FACA38;font-size: 80px;border-radius: 12px;overflow: hidden;}.bottom {position: absolute;left: 0;top: 50%;width: 100%;height: 50%;line-height: 0;overflow: hidden;    /*不加这行就不会隐藏掉上面那半个数字部分*/background: -webkit-linear-gradient(#fe4e4e, #bd2a2a); /* Safari 5.1 - 6.0 */background: -o-linear-gradient(#fe4e4e, #bd2a2a); /* Opera 11.1 - 12.0 */background: -moz-linear-gradient( #fe4e4e, #bd2a2a); /* Firefox 3.6 - 15 */background: linear-gradient(#fe4e4e, #bd2a2a); /* 标准的语法 */}.animate {animation-name: flip;animation-duration: 1s;animation-direction: normal;animation-fill-mode: forwards;}.animate1 {animation-delay: .3s;-webkit-animation-delay: .3s;}.animate2 {animation-delay: .6s;}.animate3 {animation-delay: .9s;}.animate4 {animation-delay: 1.2s;}.animate5 {animation-delay: 1.5s;}.animate6 {animation-delay: 1.8s;}.animate7 {animation-delay: 2.1s;}.animate8 {animation-delay: 2.4s;}.animate9 {animation-delay: 2.7s;}@keyframes flip{from {transform: rotateX(180deg);width: 100%;}to {transform: rotateX(0);}}</style>
</head>
<body><div class="container"><div class="item"><!--底下那层--><div class="under">9</div><!--上面会翻动的那层--><div class="on animate animate0"><!--只需要下面那一半--><div class="bottom">9</div></div></div><div class="item"><div class="under">8</div><div class="on animate animate1"><div class="bottom"><div class="num">8</div></div></div></div><div class="item"><div class="under">7</div><div class="on animate animate2"><div class="bottom"><div class="num">7</div></div></div></div><div class="item"><div class="under">6</div><div class="on animate animate3"><div class="bottom"><div class="num">6</div></div></div></div><div class="item"><div class="under">5</div><div class="on animate animate4"><div class="bottom"><div class="num">5</div></div></div></div><div class="item"><div class="under">4</div><div class="on animate animate5"><div class="bottom"><div class="num">4</div></div></div></div><div class="item"><div class="under">3</div><div class="on animate animate6"><div class="bottom"><div class="num">3</div></div></div></div><div class="item"><div class="under">2</div><div class="on animate animate7"><div class="bottom"><div class="num">2</div></div></div></div><div class="item"><div class="under">1</div><div class="on animate animate8"><div class="bottom"><div class="num">1</div></div></div></div><div class="item"><div class="under">0</div><div class="on animate animate9"><div class="bottom"><div class="num">0</div></div></div></div></div>
</body>
</html>


http://www.ppmy.cn/devtools/14217.html

相关文章

node.js 解析post请求 方法一

前提&#xff1a;依旧以前面发的node.js服务器动态资源处理代码 具体见 http://t.csdnimg.cn/TSNW9为模板&#xff0c;在这基础上进行修改。与动态资源处理代码不同的是&#xff0c;这次的用户信息我们借用表单来实现。post请求解析来获取和展示用户表单填写信息 1》代码难点&…

❤️新版Linux零基础快速入门到精通——第一部分❤️

❤️新版Linux零基础快速入门到精通——第一部分❤️ 非科班的我&#xff01;Ta&#xff01;还是来了~~~1. 来认识一下Linux吧!1.1 操作系统概述1.1.1 操作系统概述1.1.2 操作系统的发展史1.1.2.1 Unix1.1.2.2 Minix1.1.2.3 Linux 1.1.3 操作系统的发展 1.2 Linux初识1.2.1 Lin…

力扣经典150题第三十九题:赎金信

目录 力扣经典150题第三十九题&#xff1a;赎金信引言题目详解解题思路代码实现示例演示复杂度分析总结 力扣经典150题第三十九题&#xff1a;赎金信 引言 本篇博客介绍了力扣经典150题中的第三十九题&#xff1a;赎金信。题目要求判断字符串 ransomNote 是否能由字符串 maga…

计算机网络4——网络层2

文章目录 一、地址解析协议ARP二、IP数据报格式1、IP 数据报首部的固定部分中的各字段2、IP 数据报首部的可变部分 三、IP 层转发分组的过程1、流程2、案例分析3、最长前缀匹配4、分组转发算法5、使用二叉线索查找转发表 一、地址解析协议ARP 在实际应用中&#xff0c;我们经常…

数据可视化-ECharts Html项目实战(14)

在之前的文章中&#xff0c;我们深入学习ECharts鼠标左键触发。想了解的朋友可以查看这篇文章。同时&#xff0c;希望我的文章能帮助到你&#xff0c;如果觉得我的文章写的不错&#xff0c;请留下你宝贵的点赞&#xff0c;谢谢。 数据可视化-ECharts Html项目实战&#xff08;…

路由过滤与引入

实验要求与拓扑 实验思路 1.配置IP 2.分别启动rip协议和ospf协议&#xff0c;实现内布互通&#xff1b; 3.路由引入 --- 让两个rip和ospf两个协议可以相互学习路由&#xff1b; 4.在做路由引入的时候&#xff0c;做路由过滤&#xff0c;避免R4的环回被RIP学到&#xff1b; 5.使…

面试算法题之暴力求解

这里写目录标题 1 回溯1.1 思路及模板1.1 plus 排列组合子集问题1.2 例题1.2.1 全排列1.2.2 N 皇后1.2.3 N皇后问题 II1.2.4 子集 &#xff08;子集/排列问题&#xff09;1.2.4 组合(组合/子集问题)1.2.5 全排列 &#xff08;排列问题&#xff09;1.2.1做过1.2.6 子集II &#…

谷歌发布基于声学建模的无限虚拟房间增强现实鲁棒语音识别技术

声学室模拟允许在AR眼镜上以最少的真实数据进行训练&#xff0c;用于开发鲁棒的语音识别声音分离模型。 随着增强现实&#xff08;AR&#xff09;技术的强大和广泛应用&#xff0c;它能应用到各种日常情境中。我们对AR技术的潜能感到兴奋&#xff0c;并持续不断地开发和测试新…