使用HTML+CSS 动画效果实现简单的钟表效果

为了显示更明显时间整体调快了一些

使用animation动画效果实现简单的带有时分秒针的钟表

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* .clock-wrapper{
            width: 400px;
            height: 400px;
            background-color: yellowgreen;
            animation: cl-run 60s steps(60);
        }
        .clock{
            width: 5px;
            height: 200px;
            background-color: red;
            margin: 0 auto;
        } */

        /* 表盘样式 */
        .clock{
            width: 400px;
            height: 400px;
            /* background-color: aqua; */
            border-radius: 50%;
            /* border: 2px solid black; */
            position:relative;
            margin: 50px auto;
            background-image: url(./img/10/表盘.webp);
            background-size: contain;
        }
        .clock div{
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            margin: auto;
        }
        /* 时针 */
        .hour-wrapper{
            width: 40%;
            height: 40%;
            /* background-color: red; */
            animation: cl-run 7200s linear infinite;
        }
        .hour-wrapper .hour{
            height: 50%;
            width: 6px;
            background-color: black;
            margin: 0 auto;
        }

        /* 分针 */
        .min-wrapper{
            width: 55%;
            height: 55%;
            /* background-color: red; */
            animation: cl-run 600s steps(60) infinite;
        }
        .min-wrapper .min{
            height: 50%;
            width: 4px;
            background-color: black;
            margin: 0 auto;
        }

        /* 秒针 */
        .sec-wrapper{
            width: 70%;
            height: 70%;
            /* background-color: red; */
            animation: cl-run 10s steps(60) infinite;
        }
        .sec-wrapper .sec{
            height: 50%;
            width: 2px;
            background-color: black;
            margin: 0 auto;
        }
      
        @keyframes cl-run{
            form{
                transform: rotateZ(0);
            }
            to{
                transform: rotateZ(360deg);
            }
        }
    </style>
</head>
<body>
    <!-- <div class="clock-wrapper">
        <div class="clock">
        </div>
    </div> -->

    <!-- 钟表容器  -->
    <div class="clock">
        <!-- 时针容器 -->
        <div class="hour-wrapper">
            <!-- 时针 -->
            <div class="hour">

            </div>
        </div>
         <!-- 分针容器 -->
         <div class="min-wrapper">
            <!-- 分针 -->
            <div class="min">
                
            </div>
        </div>
         <!-- 秒针容器 -->
         <div class="sec-wrapper">
            <!-- 秒针 -->
            <div class="sec">
                
            </div>
        </div>
    </div>
    
</body>
</html>

最终实现效果:为了效果明显,将秒针一圈调为了十秒

视频不知道怎么发 

 

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值