当前位置:   article > 正文

CSS3动画之实现大话西游师徒四人走动_animation 师徒四人

animation 师徒四人

CSS3动画之实现大话西游师徒四人走动

该动画实现所需素材如下:

背景图
在这里插入图片描述
师徒四人

在这里插入图片描述
在这里插入图片描述在这里插入图片描述在这里插入图片描述最终效果
在这里插入图片描述

这里主要使用的是 动画animation-timing-function: steps(7, end);
将图片分成八份逐帧播放

完整代码:

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

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>大话西游</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    .bg {
      height: 720px;
      width: 100%;
      background-image: url(./大话西游/background.jpg);
      background-position: right;
      background-repeat: repeat-x;
      float: left;
      position: relative;
      animation-name: bg;
      animation-duration: 15s;
      animation-timing-function: linear;
      animation-iteration-count: infinite;

    }

    .ts {
      height: 200px;
      width: 170px;
      float: left;
      position: absolute;
      top: 400px;
      left: 600px;
      background-image: url(./大话西游/ts.png);
      animation-name: ts;
      animation-duration: 1s;
      animation-timing-function: steps(7, end);
      animation-iteration-count: infinite;
    }


    .wk {
      height: 180px;
      width: 170px;
      float: left;
      position: absolute;
      top: 400px;
      left: 300px;
      background-image: url(./大话西游/wk.png);
      animation-name: wk;
      animation-duration: 1s;
      animation-timing-function: steps(7, end);
      animation-iteration-count: infinite;
    }

    .bj {
      height: 180px;
      width: 200px;
      float: left;
      position: absolute;
      top: 400px;
      left: 450px;
      background-image: url(./大话西游/bj.png);
      animation-name: bj;
      animation-duration: 1s;
      animation-timing-function: steps(7, end);
      animation-iteration-count: infinite;
    }

    .ss {
      height: 200px;
      width: 200px;
      float: left;
      position: absolute;
      top: 400px;
      left: 780px;
      background-image: url(./大话西游/ss.png);
      animation-name: ss;
      animation-duration: 1s;
      animation-timing-function: steps(7, end);
      animation-iteration-count: infinite;
    }

    @keyframes bg {
      0% {
        background-position: 0 0;
      }

      100% {
        background-position: 1900px 0;
      }

    }

    @keyframes ts {
      0% {
        background-position: 0 0;
      }

      100% {
        background-position: -1180px 0;
      }
    }

    @keyframes wk {
      0% {
        background-position: 0 0;
      }

      100% {
        background-position: -1400px 0;
      }
    }

    @keyframes bj {
      0% {
        background-position: 0 0;
      }

      100% {
        background-position: -1400px 0;
      }
    }

    @keyframes ss {
      0% {
        background-position: 0 0;
      }

      100% {
        background-position: -1450px 0;
      }
    }
  </style>
</head>

<body>

  <div class="bg"></div>
  <div class="ts">
  </div>
  <div class="wk">
  </div>
  <div class="bj">
  </div>
  <div class="ss">
  </div>

</body>

</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/887403
推荐阅读
相关标签
  

闽ICP备14008679号