css3實現一個類似秒針旋轉的效果

效果如下圖所示(沒有做成gif,嘿嘿嘿)
在這裏插入圖片描述

<style>
  .second-bar-box{
     width: 100px;
     height: 100px;
     border-radius: 50%;
     border: 1px solid #db192a;
     position: relative;
   }

   .second-bar{
     position: absolute;
     left: 50%;
     top: 0;
     width: 2px;
     height: 50px;
     margin-left: -1px;
     background-color: #ccc;
     animation: barMove 60s linear infinite; /*動畫名稱、持續時間、運動方式、重複形式(也可以寫成具體次數,例如:5)*/
     transform-origin: center bottom; /*控制以哪個點爲中心點*/
   }

   @keyframes barMove {
     0% {
       transform: rotateZ(0deg);
     }
     100% {
       transform: rotateZ(360deg);
     }
   }
 </style>

<div class="second-bar-box">
    <div class="second-bar"></div>
 </div>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章