1 Star 0 Fork 0

math.most/html-css

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
012动画案例(时钟).html 4.40 KB
一键复制 编辑 原始数据 按行查看 历史
math.most 提交于 2021-09-27 19:40 +08:00 . first commit
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>动画案例(时钟)</title>
<style>
* {
padding: 0;
margin: 0;
}
.clock {
width: 300px;
height: 300px;
border: 10px solid #ccc;
border-radius: 160px;
margin: 100px auto;
position: relative;
}
.line {
width: 8px;
height: 300px;
background-color: #ccc;
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, 0);
}
.line2 {
width: 8px;
height: 300px;
background-color: #ccc;
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, 0) rotate(30deg);
}
.line3 {
width: 8px;
height: 300px;
background-color: #ccc;
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, 0) rotate(60deg);
}
.line4 {
width: 8px;
height: 300px;
background-color: #ccc;
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, 0) rotate(90deg);
}
.line5 {
width: 8px;
height: 300px;
background-color: #ccc;
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, 0) rotate(120deg);
}
.line6 {
width: 8px;
height: 300px;
background-color: #ccc;
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, 0) rotate(150deg);
}
.cover {
width: 250px;
height: 250px;
background-color: #fff;
border-radius: 50%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.hour {
width: 6px;
height: 80px;
background-color: red;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -100%);
/* 设置旋转轴心 */
transform-origin: center bottom;
/* 使用动画 */
animation: move 43200s linear infinite;
}
.minute {
width: 4px;
height: 100px;
background-color: green;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -100%);
/* 设置旋转轴心 */
transform-origin: center bottom;
/* 使用动画 */
animation: move 3600s linear infinite;
}
.second {
width: 2px;
height: 120px;
background-color: blue;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -100%);
/* 设置旋转轴心 */
transform-origin: center bottom;
/* 使用动画 */
animation: move 60s infinite steps(60);
}
.center {
width: 20px;
height: 20px;
background-color: #ccc;
border-radius: 50%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
/* 创建动画 */
@keyframes move {
from {
transform: translate(-50%, -100%) rotate(0deg);
}
to {
transform: translate(-50%, -100%) rotate(360deg);
}
}
</style>
</head>
<body>
<div class="clock">
<div class="line line1"></div>
<div class="line line2"></div>
<div class="line line3"></div>
<div class="line line4"></div>
<div class="line line5"></div>
<div class="line line6"></div>
<div class="cover"></div>
<div class="hour"></div>
<div class="minute"></div>
<div class="second"></div>
<div class="center"></div>
</div>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mathmost/html-css.git
git@gitee.com:mathmost/html-css.git
mathmost
html-css
html-css
master

搜索帮助