/**index.wxss**/ .warp { width: 600rpx; height: 600rpx; /*给大的外面设置了一个从中心点的渐变*/ background: radial-gradient(circle, white, rgb(109, 30, 30), rgb(235, 121, 118)); margin: 50rpx auto; border-radius: 400rpx; } /*时钟里面*/ .div1 { width: 500rpx; height: 500rpx; background: lavender; position: relative; top: 50rpx; left: 50rpx; border-radius: 250rpx; } .h { /*作为时针*/ width: 20rpx; height: 100rpx; background: black; position: absolute; top: 150rpx; left: 240rpx; border-top-left-radius: 10rpx; border-top-right-radius: 10rpx; /*指定旋转的中心*/ transform-origin: bottom center; /* animation: rotate360deg 43200s linear infinite; */ } .m { /*作为分针*/ width: 12rpx; height: 160rpx; background: black; position: absolute; top: 90rpx; left: 242rpx; border-top-left-radius: 10rpx; border-top-right-radius: 10rpx; /*指定旋转的中心*/ transform-origin: bottom center; /* animation: rotate360deg 3600s linear infinite; */ } .s { /*作为秒针*/ width: 7rpx; height: 200rpx; background: red; position: absolute; top: 50rpx; left: 240rpx; border-top-left-radius: 5rpx; border-top-right-radius: 5rpx; /*指定旋转的中心为左边*/ transform-origin: bottom center; /*时间为60s */ /* animation: rotate360deg 60s steps(60) infinite; */ } .div1_3 { position: absolute; width: 40rpx; height: 40rpx; border-radius: 20rpx; top: 230rpx; left: 230rpx; background: rgb(255, 230, 0); } .div1-4 { width: 500rpx; height: 5rpx; /*background: red;*/ position: absolute; top: 250rpx; /*把它设置成一个弹性盒子,并且让子元素两边对齐*/ display: flex; justify-content: space-between; } /*用旋转把一个圆分成12等分*/ .d1 { transform: rotateZ(90deg); } .d2 { transform: rotateZ(30deg); } .d3 { transform: rotateZ(60deg); } .d4 { transform: rotateZ(120deg); } .d5 { transform: rotateZ(150deg); } .left { width: 20rpx; height: 5rpx; background: black; } .right { width: 20rpx; height: 5rpx; background: black; } .d0>div, .d1>div { height: 10rpx; width: 35rpx; } /* 不采取动画,通过定时调用函数动态显示当前时间 */ /*让时针分针和秒针绕右边旋转360deg*/ /* @keyframes rotate360deg { from {} to { transform: rotateZ(360deg); } } */ .text1 { text-align: center; font-size: x-large; margin: 100rpx 0 50rpx; } .currentTime { text-align: center; font-size: xx-large; }