你會用css寫一個加載動畫嗎?

<!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>css 轉圈</title>
  <style>
    .turn{
      position: relative;
      width:100px;
      height: 100px;
      border: 10px solid #f4f4f4;
      animation:turn 1s linear infinite;      
      margin: 100px auto;
      border-radius: 50%;
    }
    .turn::after{
      position: absolute;
      content: '';
      top:0px;
      left:10px;
      width: 12px;
      height: 12px;
      background: #333;
      border-radius:50%;
    }
     .turn::before{
      position: absolute;
      content: '';
      top:-4px;
      left:16px;
      width: 12px;
      height: 12px;
      background: blue;
      border-radius:50%;
    }
    /*
      turn : 定義的動畫名稱
      1s : 動畫時間
      linear : 動畫以何種運行軌跡完成一個周期
      infinite :規(guī)定動畫應該無限次播放
     */
    @keyframes turn{
      0%{transform:rotate(0deg);}
      25%{transform:rotate(90deg);}
      50%{transform:rotate(180deg);}
      75%{transform:rotate(270deg);}
      100%{transform:rotate(360deg);}
    }
  </style>
</head>
<body>
  <div class="turn">
  </div>
</body>
</html>



作者:Vam的金豆之路

主要領域:前端開發(fā)

我的微信:maomin9761

微信公眾號:前端歷劫之路