原生css制作钟表

原生css钟表

		***下面是效果图:***

在这里插入图片描述
html代码

   <!---设置时钟-->
   <div class="clock">
       <!--设置秒针-->
       <div class="second-wrapper">
           <div class="second"></div>
       </div>
       <!--设置分针-->
       <div class="minute-wrapper">
            <div class="minute"></div>
       </div>
       <!--设置时针-->
       <div class="hour-wrapper">
            <div class="hour"></div>
       </div>
       <!--设置数字-->
       <div class="num">
           <span class="twelve">12</span>
           <span class="one">1</span>
           <span class="two">2</span>
           <span class="three">3</span>
           <span class="four">4</span>
           <span class="five">5</span>
           <span class="six">6</span>
           <span class="seven">7</span>
           <span class="eight">8</span>
           <span class="nine">9</span>
           <span class="ten">10</span>
           <span class="eleven">11</span>
       </div>
       <!--给中间点-->
       <div class="dot"></div>
   </div>

css代码

    <style>
       .clock{
           width: 500px;
           height: 500px;
           background-color: #ff9999;
           margin: 50px auto;
           border-radius: 50%;
           border: 5px solid black;
           position: relative;
           /* background-image: url("./img/bg3.jpg");
           background-size: cover; */
       }
       .clock > div{
           position: absolute;
           left: 0;
           right: 0;
           top: 0;
           bottom: 0;
           margin:auto;
       }
       /*设置秒针外部*/
       .second-wrapper{
           width:50%;   
           height:90%;
           /* background-color: #bbffaa; */
           animation: run 60s infinite steps(60);
       }
       /*设置秒针*/
       .second{
           width:3px;
           height:50%;
           background-color: red;
           margin: 0 auto;
       }
       /*设置分针外部*/
       .minute-wrapper{
           width:60%;
           height:60%;
           /* background-color: blue; */
           animation: run 3600s infinite steps(60);
       }
       /*设置分针*/
       .minute{
           width: 6px;
           height: 50%;
           background-color: black;
           margin: 0 auto;
       }
       /*设置时针外部*/
       .hour-wrapper{
           width: 30%;
           height: 30%;
           /* background-color: blueviolet; */
           animation: run 43200s infinite linear;
       }
       /*设置时针*/
       .hour{
           width: 8px;
           height: 50%;
           background-color: black;
           margin: 0 auto;
       }
       .num{
           width: 100%;
           height:100%;
           border-radius: 50%;
       }
       .twelve{
            position: absolute;
            top: 0;
            left:235px;
            bottom: 0;
            margin: 0 auto;
            color: seagreen;
            font-size: 25px;
       }
       .one{
            position: absolute;
            top:30px;
            left:372px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .two{
            position: absolute;
            top:123px;
            left:458px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .three{
            position: absolute;
            top:235px;
            left:487px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .four{
            position: absolute;
            top:355px;
            left:450px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .five{
            position: absolute;
            top:442px;
            left:364px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .six{
            position: absolute;
            top:474px;
            left:242px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .seven{
            position: absolute;
            top:442px;
            left:125px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .eight{
            position: absolute;
            top:353px;
            left:35px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .nine{
            position: absolute;
            top:235px;
            left:0px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .ten{
            position: absolute;
            top:120px;
            left:30px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       .eleven{
            position: absolute;
            top:30px;
            left:115px;
            bottom:0;
            color: seagreen;
            font-size: 25px;
       }
       /*设置中间圆点*/
       .dot{
           width: 20px;
           height: 20px;
           border-radius: 50%;
           background-color: black;
       }
        @keyframes run{
            from{
                transform: rotateZ(0);
              
            }
            to{
                transform: rotateZ(360deg);
        
            }
        }
    </style>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值