react实现时钟翻牌效果

news2024/10/5 16:20:07

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

问题:只在加载时有动效

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

git 重命名文件,提交后,此文件的提交记录丢失

零、问题现象&#xff1a; 文件重命名后&#xff0c;提交到 git 仓库&#xff0c;发现重命名操作 变成 删除旧文件&#xff0c;新增一个新文件&#xff0c;原来文件的提交记录丢失&#xff0c;看不到了。 一、正确的重命名提交方法 1.1、 先执行add命令来将修改内容后的文件…

什么是行子查询(Row Subqueries)?

什么是行子查询&#xff08;Row Subqueries&#xff09;&#xff1f; 行子查询&#xff0c;也称为行构造子查询&#xff0c;是SQL中的一种子查询形式&#xff0c;它返回单个行而不仅仅是单个字段的值。这意味着&#xff0c;与标准的标量或列子查询不同&#xff0c;行子查询可以…

解构海洋缺氧:浙大 GIS 实验室融合机器学习及卫星测绘,发布全球海表溶解氧综合建模框架

多年前&#xff0c;海洋专家 Eric Prince 在进行鱼类标记追踪时发现了一个异常现象&#xff1a;蓝色马林鱼在美国东南部通常会下潜至 800 米的深海捕食&#xff0c;而在哥斯达黎加海域却只在海洋表层活动。作为潜水行家的马林鱼&#xff0c;为什么突然不潜水了呢&#xff1f; 长…

【k8s】Kubernetes 1.29.4离线安装部署(总)

&#xff08;一&#xff09;kubernetes1.29.4离线部署之-安装文件准备 &#xff08;二&#xff09;kubernetes1.29.4离线部署之-镜像文件准备 &#xff08;三&#xff09;kubernetes1.29.4离线部署之-环境初始化 &#xff08;四&#xff09;kubernetes1.29.4离线部署之-组件安装…

Educational Codeforces Round 164 (Rated for Div. 2) A-E

A. Painting the Ribbon 暴力模拟即可 #include <bits/stdc.h>using namespace std; const int N 2e5 5; typedef long long ll; typedef pair<ll, ll> pll; typedef array<ll, 3> p3; // int mod 998244353; const int maxv 4e6 5; // #define endl &…

Maven的基础使用

1 Maven概述 引入案例&#xff1a;idea创建javaWeb项目&#xff0c;如何打包并发布tomcat上去&#xff0c;以便于客户端访问&#xff1f; 方案一&#xff1a;DOS命令完成打包&#xff0c;操作性不方便&#xff0c;代码频繁修改&#xff0c;频繁使用命令打包一阶段可以打包&am…

SHELL脚本(全是干货)

一、shell是什么&#xff1f; 1. 1 shell 是一种脚本语言 脚本语言的本质是一个文件&#xff0c;文件里面存放的是特点格式的指令&#xff0c;系统可以使用脚本解析器翻译或者解析指令&#xff0c;并且执行&#xff08;它不需要编译&#xff09; shell 即是应用程序&#xff…

【Linux】Linux权限管理详解

&#x1f331;博客主页&#xff1a;青竹雾色间 &#x1f331;系列专栏&#xff1a;Linux &#x1f618;博客制作不易欢迎各位&#x1f44d;点赞⭐收藏➕关注 目录 1. Linux权限概念2. 文件访问者分类a) 文件和目录的访问者&#xff1a;b) 文件类型和访问权限 3. 文件权限值的表…

Linux的磁盘分区,格式化,挂载

1.需要提前添加几个磁盘&#xff0c;以做实验 2.把nvme0n2磁盘用来分区实验 3.分了一个主分区&#xff0c;和一个扩展分区&#xff08;扩展分区是不能使用的&#xff0c;所以又在扩展分区里分了一个逻辑分区&#xff09;分区的大小自己定义 4.格式化分出来的区&#xff0c;这…

xgp怎么注册阿根廷账号 微软商店xgp阿根廷账号注册教程

xgp怎么注册阿根廷账号 微软商店xgp阿根廷账号注册教程 xgp游戏平台是微软公司针对pc用户开发的一款游戏平台&#xff0c;在平台内有着知名的月包服务&#xff0c;玩家们只需每个月支付固定的费用&#xff0c;即可免费玩到不同的游戏大作&#xff0c;xgp平台也正是由月包服务…

1.C++入门(下)

目录 1.引用和指针 2.内联函数 2.1 概念&#xff1a; 2.2 特性&#xff1a; 2.3 与宏对比 3.auto关键字 3.1 简介&#xff1a; ​3.2 使用&#xff1a; 3.3 局限 4.基于范围的for循环 1.引用和指针 因为这个面试中常考&#xff0c;就接着上一篇&#xff0c;把这个放…

Linux 底软开发——对CAN的详细操作(周期发送,异常检测,过滤报文)

Linux底软开发—对CAN发送接收详细操作 文章目录 Linux底软开发—对CAN发送接收详细操作1.保证多条CAN数据发送的周期性2.解析CAN报文数据3.CAN总线异常机制应对4.对CAN报文进行过滤操作5.完整的接收报文代码&#xff08;过滤&#xff0c;心跳检测&#xff0c;解析&#xff09;…

刚刚,百度真来炸场了!

文章目录 前言再看文心智能体开发工具&#xff1a;AgentBuilderAI原生应用开发工具&#xff1a;AppBuilder各种尺寸的模型定制工具&#xff1a;ModelBuilder结语 前言 不知道大家还记得不&#xff0c;去年 ChatGPT 火遍全球的时候&#xff0c;国内率先推出 AI 大模型的是百度家…

【热门话题】AI作画算法原理解析

&#x1f308;个人主页: 鑫宝Code &#x1f525;热门专栏: 闲话杂谈&#xff5c; 炫酷HTML | JavaScript基础 ​&#x1f4ab;个人格言: "如无必要&#xff0c;勿增实体" 文章目录 AI作画算法原理解析AI作画算法概述基础原理&#xff1a;机器学习与深度学习卷积…

再谈C语言——理解指针(四)

assert断⾔ assert.h 头⽂件定义了宏 assert() &#xff0c;⽤于在运⾏时确保程序符合指定条件&#xff0c;如果不符合&#xff0c;就报错终⽌运⾏。这个宏常常被称为“断⾔”。 assert(p ! NULL); 上⾯代码在程序运⾏到这⼀⾏语句时&#xff0c;验证变量 p 是否等于 NULL 。…

基于Kepware的Hadoop大数据应用构建-提升数据价值利用效能

背景 Hadoop是一个由Apache基金会所开发的分布式系统基础架构&#xff0c;它允许用户在不需要深入了解分布式底层细节的情况下&#xff0c;开发分布式程序。Hadoop充分利用集群的威力进行高速运算和存储&#xff0c;特别适用于处理超大数据集。 Hadoop的生态系统非常丰富&…

【如何使用chrome开发者工具调试javascript代码】

创作背景 平常开发时我们去解决bug可能会用console.log来来调试&#xff0c;但是断点可以更快地完成工作。 log调试的劣势&#xff1a;但是使用console.log时需要我们手动的打开源码&#xff0c;找到相关代码&#xff0c;插入log语句&#xff0c;然后重新加载页面&#xff0c…

【MySQL】数据库操作指南:数据类型篇

&#x1f331;博客主页&#xff1a;青竹雾色间 &#x1f331;系列专栏&#xff1a;MySQL探险日记 &#x1f618;博客制作不易欢迎各位&#x1f44d;点赞⭐收藏➕关注 ✨人生如寄&#xff0c;多忧何为 ✨ 文章目录 1. 数值类型1.1 tinyint 类型1.2 bit 类型1.3 小数类型1.3.1 f…

屏幕状态自动检测+鼠标自动操作

目录 一、写在前面 1.1适用场景 1.2涉及到的库 二、函数库 2.1pyautogui-屏幕截图&鼠标操作 2.1.1屏幕截图screenshot函数 2.1.2鼠标移动及单击 2.2Opencv-模板匹配 2.2.1matchTemplate函数 2.2.2minMaxLoc函数 2.2.3相关代码 2.3base64-图片转base64 2.3.1在线…

顺序表的应用-通讯录

顺序表的应用-通讯录 1.操作2.功能要求2.1.功能要求2.2.思路小结2.3.文件梳理2.4.代码实现"SeqList.h""Contact.h""SeqList.c""Contact.c""test.c" 1.操作 链接: 顺序表专题 这篇文章介绍了顺序表的概念与基本操作。 本文将…