svg+css实现大象走动动画效果代码

代码语言:html

所属分类:动画

代码描述:svg+css实现大象走动动画效果代码

代码标签: 走动 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


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

<head>

  <meta charset="UTF-8">

  
  
<style>
:root {
  --walk-speed: 600ms;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000000;
  color: #fff
}

svg {
  display: block;
  width: 90vmin;
  height: 90vmin;
}

.stroke {
  stroke: #fff;
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.shape {
  fill: #111;
  stroke: none;
}

.eye .shape {
  fill: #25c;
  stroke: none;
}

.eye .pupil {
  fill: #000;
  stroke: none;
}

.eye .pupil__reflect {
  fill: #fff;
  stroke: none;
}

.leg--front-left {
  transform-origin: 45% 66%;
  animation: leg-anim ease-in-out infinite alternate var(--walk-speed);
}

.leg--front-right {
  transform-origin: 53.3% 72.5%;
  animation: leg-anim ease-in-out infinite alternate var(--walk-speed);
  animation-delay: calc(-.75 * var(--walk-speed));
}

.leg--back-left {
  transform-origin: 73.3% 71.67%;
  animation: leg-anim ease-in-out infinite alternate var(--walk-speed);
}

.leg--back-right {
  transform-origin: 80% 72.5%;
  animation: leg-anim ease-in-out infinite alternate var(--walk-speed);
  animation-delay: calc(-.75 * var(--walk-speed));
}

.nose {
  transform-origin: 41.67% 33.33%;
  animation: nose-anim ease-in-out infinite alternate var(--walk-speed);
  animation-delay: calc(-.75 * var(--walk-speed));
}

.ear {
  transform-origin: 50% 18.33%;
  animation: ear-anim ease-in-out infinite alternate calc(var(--walk-speed) * 1);
  animation-delay: calc(-.25 * var(--walk-speed));
}

.tail {
  transform-origin: 93.125% 45.4167%;
  animation: tail-anim ease-in-out infinite alternate var(--walk-speed);
  animation-delay: calc(-.25 * var(--walk-speed));
}

@keyframes tail-anim {
  0% { transform: rotate(-4deg); }
  100% { transform: rotate(4deg); }
}

@keyframes leg-anim {
  0% { transform: rotate(-7deg); }
  100% { transform: rotate(7deg); }
}

@keyframes nose-anim {
  0% { transform: rotate(-3deg); }
  100% { transform: rotate(3deg); }
}

@keyframes ear-anim {
  0% { transform: rotate(-3deg); }
  100% { transform: rotate(3deg); }
}
</style>



</head>

<body >
  <svg role="img" aria-label="A stroke illustration of an elephant" viewBox="0 0 120 120">
  <g class="leg leg--back-left">
    <path class="shape" d="M82.5 78.5 v15 q 0 3 6 3 q 6 0 6 -3v-15z" />
    <path class="stroke" d="M82.5 78.5 v15 q 0 3 6 3 q 6 0 6 -3v-10" />
  </g>
  <g class="leg leg--front-left">
    <path class="shape" d="M61 76 v15 q 0 3 -6 3 q -6 0 -6 -3v-12 q0 -5 -6 -12 l -5 -5 l 15 -15z" />
    <path class="stroke" d="M61 76 v15 q 0 3 -6 3 q -6 0 -6 -3v-12 q0 -5 -6 -12 l-5 -5" />
  </g>
  <g class="body">
    <path class="shape" d="M58 21 l24 10 h10 q20 0 20 30 q0 10 -10 20h-12s-10 3 -20 0h-12 l -14 -17z" />
    <path class="str.........完整代码请登录后点击上方下载按钮下载查看

网友评论0