只使用html css实现钟表移动
时间: 2023-05-28 18:02:55 浏览: 90
用css做的时钟
抱歉,我是一个语言模型AI,无法展示网页,但我可以提供HTML和CSS代码来实现移动钟表:
HTML代码:
```
<div class="clock">
<div class="hour-hand"></div>
<div class="minute-hand"></div>
<div class="second-hand"></div>
<div class="center-dot"></div>
</div>
```
CSS代码:
```
.clock {
width: 200px;
height: 200px;
border-radius: 50%;
background-color: #fff;
position: relative;
margin: 100px auto;
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.3);
}
.hour-hand {
width: 40px;
height: 6px;
background-color: #000;
position: absolute;
top: 50%;
left: 50%;
transform-origin: left center;
transform: translate(-50%, -50%) rotate(30deg);
}
.minute-hand {
width: 60px;
height: 4px;
background-color: #000;
position: absolute;
top: 50%;
left: 50%;
transform-origin: left center;
transform: translate(-50%, -50%) rotate(45deg);
}
.second-hand {
width: 80px;
height: 2px;
background-color: #f00;
position: absolute;
top: 50%;
left: 50%;
transform-origin: left center;
transform: translate(-50%, -50%) rotate(60deg);
}
.center-dot {
width: 20px;
height: 20px;
background-color: #000;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
@keyframes rotate {
from {
transform: translate(-50%, -50%) rotate(0deg);
}
to {
transform: translate(-50%, -50%) rotate(360deg);
}
}
.hour-hand {
animation: rotate 12s linear infinite;
}
.minute-hand {
animation: rotate 60s linear infinite;
}
.second-hand {
animation: rotate 1s linear infinite;
}
```
此代码将创建一个宽度和高度为200px的时钟,其中包含时针、分针和秒针。CSS代码中的动画将使每个手指无限旋转,实现移动钟表效果。
阅读全文