zlx362211854 / daily-study

每日一个知识点总结,以issue的形式体现
10 stars 6 forks source link

133. 画一个loading图标 #190

Open goldEli opened 4 years ago

goldEli commented 4 years ago
  1. CSS3 Animations 属性有什么用?
  2. 利用 Animations 画一个 loading 图标(效果如下),并附上代码。

ezgif com-video-to-gif(1)

goldEli commented 4 years ago
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box{
      width: 100px;
      height: 100px;
      display: flex;
      flex-direction: row;
      justify-content: space-around;
      align-items: center;
    }
    .box div:nth-child(1){
      animation-delay: 0s;
    }
    .box div:nth-child(2){
      animation-delay: 0.25s;
    }
    .box div:nth-child(3){
      animation-delay: 0.4s;
    }
    .item{
      width: 20px;
      height: 20px;
      background-color: gray;
      border-radius: 50%;
      animation-name: move;
      animation-duration: 0.6s;
      animation-iteration-count:infinite;
      animation-direction:alternate;
    }
    @keyframes move {
      0%   {transform: translateY(-0px);opacity: 1;}
      100%  {transform: translateY(-16px);opacity: 0.2;}
    }
  </style>
</head>
<body>
  <div class="box">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
  </div>
  <script>