钟表练习 html+css实现

2021/5/21 10:31:34

本文主要是介绍钟表练习 html+css实现,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
            }
            
            /* 设置表的样式 */
            .clock{
                width: 500px;
                height: 500px;
                /* background-color: #BBFFAA; */
                margin: 0 auto;
                margin-top: 100px;
                /* 圆形 */
                border-radius: 50%;
                /* border:10px solid black; */
                position: relative;
                background-image: url(./img/13/bg.png);
                background-size: cover;
            }
            
            .clock > div{
                position: absolute;
                top: 0;
                left: 0;
                bottom: 0;
                right: 0;
                margin: auto;
            }
            
            /* 设置时针 */
            .hour-wrapper{
                
                height: 70%;
                width: 70%;
                /* background-color: #BBFFAA; */
                animation: run 43200s linear infinite;
                
            }
            
            .hour{
                height: 50%;
                width: 6px;
                background-color: #000;
                margin: 0 auto;
            }
            
            .min-wrapper{
                height: 80%;
                width: 80%;
                animation: run 3600s steps(60) infinite;
            }
            
            .min{
                height: 50%;
                width: 4px;
                background-color: #000;
                margin: 0 auto;
            }
            
            .sec-wrapper{
                height: 90%;
                width: 90%;
                /* infinite  持续输出动画 */
                animation: run 60s steps(60) infinite;
            }
            
            .sec{
                height: 50%;
                width: 2px;
                background-color: #f00;
                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>

表盘图片链接:

 



这篇关于钟表练习 html+css实现的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程