CSS有关旋转的练习
只做出了针表旋转的效果
效果图
代码
<!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>Document</title>
<style>
.clock
{
width: 500px;
height:500px;
border-radius: 50%;
/* border: 10px solid black; */
position:relative;
background-image: url(lib/img/duck.jpg);
background-size: contain;
/* background-color: #bfa; */
}
.clock > div{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
.hour-wrapper{
width: 60%;
height:60%;
animation: run 43200s steps(12) infinite;
}
.hour{
width: 5px;
height: 50%;
background-color: black;
margin: 0 auto;
}
.min-wrapper{
width: 75%;
height:75%;
animation: run 3600s steps(60) infinite;
}
.min{
width: 3px;
height: 50%;
background-color: black;
margin: 0 auto;
}
.sec-wrapper{
width: 90%;
height:90%;
animation: run 60s steps(60) infinite;
}
.sec{
width: 1px;
height: 50%;
background-color: red;
margin: 0 auto;
}
@keyframes run {
from{
transform: rotateZ(0);
}
to{
transform: rotateZ(360deg);
}
}
</style>
</head>
<body>
<div class="clock">
<div class="hour-wrapper">
<div class="hour"></div>
</div>
<div class="min-wrapper">
<div class="min"></div>
</div>
<div class="sec-wrapper">
<div class="sec"></div>
</div>
</div>
</body>
</html>
素材