html js 做一个钟表,html,css,js实现的一个钟表

这篇文章展示了如何使用CSS3和HTML创建一个3D立体时钟,通过CSS动画和定位技巧实现小时、分钟和秒针的动态效果。作者详细介绍了scale、hand和transform-origin等关键属性的运用。
摘要由CSDN通过智能技术生成
Clock

}p{color:#854d27;

}code{color:#f4c950;

}.clock{--clock-width:50vmin;width:var(--clock-width);height:var(--clock-width);position:relative;overflow:hidden;border:6px solid #f4c950;border-radius:50%;

}.clock:after{content:‘‘;position:absolute;z-index:10;top:50%;left:50%;transform:translate(-50%, -50%);width:6px;height:6px;background:#d0b8ac;border-radius:50%;

}.scaleContainer{--scale-width:2px;margin:0;padding:0;width:var(--scale-width);height:calc(var(--clock-width) / 2 + 4px);position:absolute;bottom:calc(var(--clock-width) / 2);left:calc((var(--clock-width) - var(--scale-width)) / 2);

/*background: #f4c950;*/transform-origin:center bottom;

}.scaleContainer:nth-of-type(5n + 5){--scale-width:5px;width:var(--scale-width);left:calc((var(--clock-width) - var(--scale-width)) / 2);

}.scale{height:calc(var(--clock-width) / 22);background:#f4c950;

}.scaleContainer:nth-of-type(5n + 5) .scale{height:calc(var(--clock-width) / 16);

}.hand{--hand-width:4px;--hand-length:calc(var(--clock-width) / 2 - 6px);width:var(--hand-width);height:var(--hand-length);background:#d0b8ac;position:absolute;bottom:calc(var(--clock-width) / 2);left:calc((var(--clock-width) - var(--hand-width)) / 2);transform-origin:center bottom;z-index:20;

}.hour-hand{height:15vmin;

}.minute-hand{--hand-height:20vmin;height:var(--hand-height);

}.second-hand{--hand-width:2px;width:var(--hand-width);left:calc((var(--clock-width) - var(--hand-width)) / 2);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值