css3動畫做一個超簡單的時鍾


話不多說,直接上代碼,自己可以設置更漂亮的樣子。我的比較丑

 

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
/*設置時鍾的樣子*/
.warp{
width: 580px;
height: 580px;
background: black;
margin: 100px auto;
border-radius: 295px;
}
.div1{
width: 500px;
height: 500px;
background: lavender;
position: relative;
top: 40px;
left: 40px;
border-radius: 250px;
}
.div1_1{
/*作為時針*/
width: 130px;
height: 30px;
background: black;
position: absolute;
top: 250px;
left: 250px;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
/*指定旋轉的中心為左邊*/
transform-origin: left center;
/*時間為3600s ,但這里為了看效果我設置成60s*/
animation: 60s m linear infinite;
}
.div1_2{
/*作為分針*/
width: 230px;
height: 30px;
background: black;
position: absolute;
top: 250px;
left: 250px;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
/*指定旋轉的中心為左邊*/
transform-origin: left center;
/*時間為60s ,但這里為了看效果我設置成10s*/
animation: 10s s linear infinite;
}
.div3{
position: absolute;
width: 50px;
height: 50px;
border-radius: 25px;
top: 240px;
left: 230px;
background: yellow;
}
/*讓分針和秒針繞右邊旋轉360deg*/
@keyframes m{
from{}
to{ transform: rotateZ(360deg);}
}
@keyframes s{
from{}
to{ transform: rotateZ(360deg);}
}

</style>
</head>
<body>
<div class="warp">
<div class="div1">
<div class="div1_1">

</div>
<div class="div1_2">

</div>
<div class="div3">

</div>
</div>
</div>

</body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM