html代码可爱钟表
导读:今天我们来谈谈一个可爱的钟表,它是用HTML代码来制作的! <div id="clock"> <div id="hour"></div> <div id="minute"><...
今天我们来谈谈一个可爱的钟表,它是用HTML代码来制作的!
div id="clock">
div id="hour">
/div>
div id="minute">
/div>
div id="second">
/div>
div id="center">
/div>
/div>
style>
#clock {
width: 200px;
height: 200px;
border-radius: 50%;
background-color: #f8c6c0;
position: relative;
}
#hour {
width: 20px;
height: 60px;
background-color: #4a4a4a;
position: absolute;
top: 50px;
left: 90px;
transform-origin: bottom center;
}
#minute {
width: 15px;
height: 100px;
background-color: #4a4a4a;
position: absolute;
top: 40px;
left: 92.5px;
transform-origin: bottom center;
}
#second {
width: 10px;
height: 120px;
background-color: #4a4a4a;
position: absolute;
top: 30px;
left: 95px;
transform-origin: bottom center;
}
#center {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: white;
position: absolute;
top: 90px;
left: 90px;
}
@keyframes hour-rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes minute-rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes second-rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#hour {
animation: hour-rotation 12s linear infinite;
}
#minute {
animation: minute-rotation 60s linear infinite;
}
#second {
animation: second-rotation 60s linear infinite;
}
/style>
如上所示,这个钟表的HTML代码非常简单,使用了基本的div标签和CSS样式进行设计。
我们可以看到,用div标签分别制作了"hour"、"minute"、"second"三个指针和"center"表盘中心。CSS样式定义了它们的位置、颜色和动画效果。
最后,我们可以得到一个超级可爱的钟表,它动起来是不是很棒呢?
div id="clock">
div id="hour">
/div>
div id="minute">
/div>
div id="second">
/div>
div id="center">
/div>
/div>
#clock {
width: 200px;
height: 200px;
border-radius: 50%;
background-color: #f8c6c0;
position: relative;
}
#hour {
width: 20px;
height: 60px;
background-color: #4a4a4a;
position: absolute;
top: 50px;
left: 90px;
transform-origin: bottom center;
}
#minute {
width: 15px;
height: 100px;
background-color: #4a4a4a;
position: absolute;
top: 40px;
left: 92.5px;
transform-origin: bottom center;
}
#second {
width: 10px;
height: 120px;
background-color: #4a4a4a;
position: absolute;
top: 30px;
left: 95px;
transform-origin: bottom center;
}
#center {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: white;
position: absolute;
top: 90px;
left: 90px;
}
@keyframes hour-rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes minute-rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes second-rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#hour {
animation: hour-rotation 12s linear infinite;
}
#minute {
animation: minute-rotation 60s linear infinite;
}
#second {
animation: second-rotation 60s linear infinite;
}
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: html代码可爱钟表
本文地址: https://pptw.com/jishu/541100.html
