CSS3 動畫(圓點閃爍動畫效果的實現)

代碼如下 

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<style>
  .point {
    width: 50px;
    height: 50px;
    background-color: #2ea598;
    position: relative;
    border-radius: 50%;
  }

  /* 設置動畫前顏色 */
  .point-flicker:after {
    background-color: #2ea598;
  }

  /* 設置動畫後顏色 */
  .point-flicker:before {
    background-color: rgba(0, 168, 253, 0.2);
  }

  /* 設置動畫 */
  .point-flicker:before,
  .point-flicker:after {
    content: '';
    width: 80px;
    height: 80px;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -40px;
    margin-top: -40px;
    border-radius: 50%;
    /* CSS3 animation 屬性 網址 */
    /* https://www.w3school.com.cn/cssref/pr_animation.asp */
    animation: warn 1.5s ease-out 0s infinite;
  }

  /* @keyframes 規則用於創建動畫。在 @keyframes 中規定某項 CSS 樣式,就能創建由當前樣式逐漸改爲新樣式的動畫效果。 */
  @keyframes warn {
    0% {
      transform: scale(0.5);
      opacity: 1;
    }

    30% {
      opacity: 1;
    }

    100% {
      transform: scale(1.4);
      opacity: 0;
    }
  }
</style>

<body>
  <div class="point point-flicker">

  </div>
</body>
<script>


</script>

</html>

效果如圖

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章