react实现时钟翻牌效果

2024-04-25 01:52

本文主要是介绍react实现时钟翻牌效果,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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

问题:只在加载时有动效

解决方案:通过判断数字改变(这里通过新旧数值变动来判断,不贴代码啦),每次变动的时候手动把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>

这篇关于react实现时钟翻牌效果的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/933419

相关文章

使用Python和OpenCV库实现实时颜色识别系统

《使用Python和OpenCV库实现实时颜色识别系统》:本文主要介绍使用Python和OpenCV库实现的实时颜色识别系统,这个系统能够通过摄像头捕捉视频流,并在视频中指定区域内识别主要颜色(红... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间详解

PostgreSQL中MVCC 机制的实现

《PostgreSQL中MVCC机制的实现》本文主要介绍了PostgreSQL中MVCC机制的实现,通过多版本数据存储、快照隔离和事务ID管理实现高并发读写,具有一定的参考价值,感兴趣的可以了解一下... 目录一 MVCC 基本原理python1.1 MVCC 核心概念1.2 与传统锁机制对比二 Postg

SpringBoot整合Flowable实现工作流的详细流程

《SpringBoot整合Flowable实现工作流的详细流程》Flowable是一个使用Java编写的轻量级业务流程引擎,Flowable流程引擎可用于部署BPMN2.0流程定义,创建这些流程定义的... 目录1、流程引擎介绍2、创建项目3、画流程图4、开发接口4.1 Java 类梳理4.2 查看流程图4

C++中零拷贝的多种实现方式

《C++中零拷贝的多种实现方式》本文主要介绍了C++中零拷贝的实现示例,旨在在减少数据在内存中的不必要复制,从而提高程序性能、降低内存使用并减少CPU消耗,零拷贝技术通过多种方式实现,下面就来了解一下... 目录一、C++中零拷贝技术的核心概念二、std::string_view 简介三、std::stri

C++高效内存池实现减少动态分配开销的解决方案

《C++高效内存池实现减少动态分配开销的解决方案》C++动态内存分配存在系统调用开销、碎片化和锁竞争等性能问题,内存池通过预分配、分块管理和缓存复用解决这些问题,下面就来了解一下... 目录一、C++内存分配的性能挑战二、内存池技术的核心原理三、主流内存池实现:TCMalloc与Jemalloc1. TCM

OpenCV实现实时颜色检测的示例

《OpenCV实现实时颜色检测的示例》本文主要介绍了OpenCV实现实时颜色检测的示例,通过HSV色彩空间转换和色调范围判断实现红黄绿蓝颜色检测,包含视频捕捉、区域标记、颜色分析等功能,具有一定的参考... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间

全面解析HTML5中Checkbox标签

《全面解析HTML5中Checkbox标签》Checkbox是HTML5中非常重要的表单元素之一,通过合理使用其属性和样式自定义方法,可以为用户提供丰富多样的交互体验,这篇文章给大家介绍HTML5中C... 在html5中,Checkbox(复选框)是一种常用的表单元素,允许用户在一组选项中选择多个项目。本

HTML5 搜索框Search Box详解

《HTML5搜索框SearchBox详解》HTML5的搜索框是一个强大的工具,能够有效提升用户体验,通过结合自动补全功能和适当的样式,可以创建出既美观又实用的搜索界面,这篇文章给大家介绍HTML5... html5 搜索框(Search Box)详解搜索框是一个用于输入查询内容的控件,通常用于网站或应用程

Python实现精准提取 PDF中的文本,表格与图片

《Python实现精准提取PDF中的文本,表格与图片》在实际的系统开发中,处理PDF文件不仅限于读取整页文本,还有提取文档中的表格数据,图片或特定区域的内容,下面我们来看看如何使用Python实... 目录安装 python 库提取 PDF 文本内容:获取整页文本与指定区域内容获取页面上的所有文本内容获取

基于Python实现一个Windows Tree命令工具

《基于Python实现一个WindowsTree命令工具》今天想要在Windows平台的CMD命令终端窗口中使用像Linux下的tree命令,打印一下目录结构层级树,然而还真有tree命令,但是发现... 目录引言实现代码使用说明可用选项示例用法功能特点添加到环境变量方法一:创建批处理文件并添加到PATH1