前端代码编写小时钟

本文介绍如何利用前端技术JavaScript、HTML5和CSS实现一个小时钟。难点在于确保指针在正确位置并能平滑旋转,最终效果令人满意。
摘要由CSDN通过智能技术生成

前端代码编写小时钟

没有用到图片,指针也是自己用自己写的。主要难度就在于指针位置的固定与旋转。

* {
   
            margin: 0;
            padding: 0;
        }

        #one {
   
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 0 auto;
            width: 750px;
            height: 150px;
            border: 1px solid;
            border-radius: 10px;
            background: linear-gradient(#086cc1, #6ba9e1);
            color: white;
        }

        li {
   
            display: flex;
            justify-content: center;
            align-items: center;
            list-style: none;
            float: left;
            width: 250px;
            height: 100px;
        }

        #clock {
   
            width: 100px;
            height: 100px;
            border: 1px solid;
            border-radius: 50px;
            position: relative;
            left: 30px;
            transform: rotate(-90deg);
        }

        #clock .bg {
   
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background: #fff;
            position: absolute;
            left: 50%;
            top: 50%;
        }

        #clock .point {
   
            position: absolute;
            left: 50%;
            top: 50%;
        }

        #clock #hour {
   
            width: 30px;
            height: 2px;
            background: #fff;
            margin: -1px 0 0 0 0;
            transform-origin: 0 0.5px;
            border-radius: 10px;
        }

        #clock #minute {
   
            width: 40px;
            height: 2px;
            background: black;
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

倪行

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值