css实现小人跑步嘚瑟动画效果代码

代码语言:html

所属分类:动画

代码描述:css实现小人跑步嘚瑟动画效果代码

代码标签: css 小人 跑步 嘚瑟 动画

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


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

<head>

  <meta charset="UTF-8">
  

  
  
  
  
<style>
:root {
  --main-color: rgb(0, 128, 0);
  --main-color-dark: rgb(0, 100, 0);
  --unit: 0.85vw;
  --time: 1.5s;
}

body {
  height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background-color: #5ec96b;
  background-image: linear-gradient(0deg, #5ec96b 0%, #e9e9e9 100%);
}

.ground {
  position: absolute;
  bottom: calc(6 * var(--unit));
  width: calc(64 * var(--unit));
  height: calc(4 * var(--unit));
  background-color: var(--main-color);
  border-radius: calc(2 * var(--unit));
}

.dude {
  position: absolute;
  bottom: calc(20 * var(--unit));
}

.upper-body {
  position: relative;
  left: 0;
  bottom: 0;
  width: calc(28 * var(--unit));
  height: calc(36 * var(--unit));
  -webkit-animation-name: shuffle;
          animation-name: shuffle;
  -webkit-animation-duration: calc(0.5 * var(--time));
          animation-duration: calc(0.5 * var(--time));
  -webkit-animation-iteration-count: infinite;
          animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in-out;
          animation-timing-function: ease-in-out;
  -webkit-animation-delay: calc(-0.25 * var(--time));
          animation-delay: calc(-0.25 * var(--time));
}

.melon {
  position: absolute;
  right: 0;
  top: 0;
  width: calc(8 * var(--unit));
  height: calc(8 * var(--unit));
  background-color: var(--main-color);
  border-radius: calc(0.5 * var(--unit)) calc(0.5 * var(--unit)) 50% 50%;
  -webkit-animation-name: nod;
          animation-name: nod;
  -webkit-animation-duration: calc(1 * var(--time));
          animation-duration: calc(1 * var(--time));
  -webkit-animation-iteration-count: infinite;
          animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in-out;
          animation-timing-function: ease-in-out;
  -webkit-animation-direction: alternate;
          animation-direction: alternate;
  -webkit-animation-delay: calc(-1.5 * var(--time));
          animation-delay: calc(-1.5 * var(--time));
  transform-origin: 25% 75%;
}

.gut {
  position: absolute;
  width: calc(28 * var(--unit));
  height: calc(28 * var(--unit));
  top: calc(8 * var(--unit));
  background-color: var(--main-color-dark);
  background-image: radial-gradient(closest-corner at 30% 30%, var(--main-color) 15%, var(--main-color-dark) 175%);
  border-radius: 50%;
  z-index: 2;
}

.arm-left,
.arm-right {
  position: absolute;
  left: 60%;
  top: 35%;
  width: calc(7 * var(--unit));
  height: calc(14 * var(--unit));
  background-color: var(--main-color);
  transform-origin: calc(3.5 * var(--unit)) calc(3.5 * var(--unit));
  border-radius: calc(3.5 * var(--unit));
  -webkit-animation-name: swing;
          animation-name: swing;
  -webkit-animation-duration: calc(0.5 * var(--time));
          animation-duration: calc(0.5 * var(--time));
  -webkit-animation-iteration-count: infinite;
          animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in-out;
          animation-timing-function: ease-in-out;
  -webkit-animation-direction: alternate;
          animation-direction: alternate;
}

.arm-right {
  -webkit-animation-delay: 0s;
          animation-delay: 0s;
  z-index: 3;
}

.arm-left {
  z-index: 1;
  animation-direction: alternate-reverse;
}

.arm-left::after,
.arm-right::after {
  content: "";
  position: absolute;
  width: calc(15 * var(--unit));
  height: calc(6 * var(--unit));
  left: 0;
  bottom: 0;
  background-color: var(--main-color-light);
  transform-origin: calc(3 * var(--unit)) calc(3 * var(--unit));
  border-radius: calc(3 * var(--unit)) calc(0.5 * var(--unit)) calc(3 * var(--unit)) calc(3 * var(--unit));
  -webkit-animation-name: swing-swing;
          animation-name: swing-swing;
  -webkit-animation-duration: calc(0.5 * var(--time));
          animation-duration: calc(0.5 * var(--time));
  -webkit-animation-iteration-count: infinite;
          animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in-out;
          animation-timing-function: ease-in-out;
  animation-direction: alternate-reverse;
  -webkit-animation-delay: calc(-0.5 * var(--time));
          animation-delay: calc(-0.5 * var(--time));
}

.arm-left::after {
  background-color: var(--main-color-dark);
  background-image: linear-.........完整代码请登录后点击上方下载按钮下载查看

网友评论0