前端的学习之路:初级CSS---时钟原理练习

时钟原理练习

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>时钟原理练习</title>
    <!-- <link rel="stylesheet" href="../chujicss/css/11.28.06.css"> -->
    <style>
       *{
           margin: 0;
           padding: 0;
       } 
       /* 设置钟表的样式 */
       .clock{
           width: 500px;
           height: 500px;
           margin: 0 auto;
           margin-top: 100px;
           border-radius: 50%;
           background-image: url(./chujicss\ img/11.28.01.jpg);
           background-size: cover;
           background-position-x: 50%;
           background-position-y: 50%;
           
           /* border:4px solid gray; */
           position: relative;
       }
       .clock>div{
           position: absolute;
           top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: auto;
       }
       /* 设置时针 */
       .hour-wrapper{
           height: 40%;
           width: 40%;
           /* background-color: #bfa; */
           animation: run 43200s infinite linear;
       }
       .hour{
           height: 50%;
           width: 6px;
           background-color: #000;
           margin: 0 auto;
       }
       .min-wrapper{
           height: 50%;
           width: 50%;
           /* background-color:red; */
           animation: run 3600s steps(60) infinite;
       }
       .min{
           height: 50%;
           width: 4px;
           background-color:black;
           margin: 0 auto;
       }
       .sec-wrapper{
           height: 65%;
           width: 65%;
           /* background-color:orchid; */
           animation: run 60s steps(60) infinite;
       }
       .sec{
           height: 50%;
           width: 2.2px;
           background-color:red;
           margin: 0 auto;
          
       }
       @keyframes run {
            from{
                transform: rotateZ(0);
            }
            to{
                transform: rotateZ(360deg);
            }
        }
    </style>
</head>
<body>
    <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>

运行结果为:
在这里插入图片描述
代码引用的图片是:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值