Dancing Cactus by

Luiz Otávio

On: 18 Jul 2016

Personal site: http://codepen.io/superoak

<div class="circle">
  <div class="floor"></div>
  <div class="sun"></div>
  <div class="cactus">
    <div class="body"></div>
    <div class="eye left"></div>
    <div class="eye right"></div>
    <div class="mouth"></div>
    <div class="arm left"></div>
    <div class="arm right"></div>
  </div>
  <div class="sand"></div>
</div>
body {
  background-color: #fff9e2;
}

.circle {
  position: absolute;
  left: 50%;
  top: 20px;
  margin-left: -150px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background-color: #f1dc5d;
  position: relative;
  overflow: hidden;
  box-shadow: 0 9px 14px rgba(0, 0, 0, 0.4);
  -webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
}

.floor {
  position: absolute;
  bottom: 0;
  left: 0;
  background-color: #ffd092;
  width: 300px;
  height: 80px;
}

.sun {
  position: absolute;
  left: 0;
  top: -30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: #fce331;
}
.sun:after, .sun:before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -50px;
  margin-top: -50px;
  width: 100px;
  height: 100px;
  background-color: white;
  border-radius: 50%;
  opacity: .2;
  -webkit-animation: glow 1s linear infinite alternate;
          animation: glow 1s linear infinite alternate;
}
.sun:after {
  -webkit-transform: scale(1.4);
          transform: scale(1.4);
}
.sun:before {
  -webkit-transform: scale(1.8);
          transform: scale(1.8);
}

.sand {
  position: absolute;
  bottom: 0;
  left: 50%;
  margin-left: -70px;
  width: 140px;
  height: 40px;
  background-color: #ffe6c7;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.cactus {
  position: absolute;
  left: 50%;
  margin-left: -25px;
  top: 40px;
  -webkit-animation: swing 500ms ease-in-out infinite alternate;
          animation: swing 500ms ease-in-out infinite alternate;
  -webkit-transform-origin: center bottom;
          transform-origin: center bottom;
}
.cactus .body {
  width: 50px;
  height: 250px;
  background-color: #52ae32;
  border-radius: 50px;
}
.cactus .arm {
  position: absolute;
  width: 25px;
  height: 100px;
  background: #52ae32;
  border-radius: 50px;
  -webkit-animation: arms 500ms ease-in-out infinite alternate;
          animation: arms 500ms ease-in-out infinite alternate;
}
.cactus .arm:after {
  content: "";
  position: absolute;
  bottom: 0;
  border-radius: 0 0 0 20px;
  width: 55px;
  height: 25px;
  background: #52ae32;
}
.cactus .arm.left {
  top: 30px;
  left: -50px;
}
.cactus .arm.right {
  top: 40px;
  left: auto;
  right: -50px;
  -webkit-animation-delay: 500ms;
          animation-delay: 500ms;
}
.cactus .arm.right:after {
  right: 0;
  border-radius: 0 0 20px 0;
}
.cactus .eye {
  position: absolute;
  top: 40px;
  width: 15px;
  height: 15px;
  background-color: white;
  border-radius: 50%;
  -webkit-animation: blink 2s ease-in-out infinite alternate;
          animation: blink 2s ease-in-out infinite alternate;
}
.cactus .eye:after {
  content: "";
  position: absolute;
  left: 1px;
  top: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #333;
}
.cactus .eye.left {
  left: 2px;
}
.cactus .eye.right {
  right: 2px;
}
.cactus .mouth {
  position: absolute;
  left: 15px;
  top: 42px;
  width: 20px;
  height: 20px;
  border-bottom: 3px solid #333;
  border-radius: 50% / 20%;
}

@-webkit-keyframes arms {
  from {
    -webkit-transform: translateY(-5px);
            transform: translateY(-5px);
  }
  to {
    -webkit-transform: translateY(5px);
            transform: translateY(5px);
  }
}

@keyframes arms {
  from {
    -webkit-transform: translateY(-5px);
            transform: translateY(-5px);
  }
  to {
    -webkit-transform: translateY(5px);
            transform: translateY(5px);
  }
}
@-webkit-keyframes blink {
  0%, 10%, 20%, 100% {
    -webkit-transform: scaleY(1);
            transform: scaleY(1);
  }
  15% {
    -webkit-transform: scaleY(0);
            transform: scaleY(0);
  }
}
@keyframes blink {
  0%, 10%, 20%, 100% {
    -webkit-transform: scaleY(1);
            transform: scaleY(1);
  }
  15% {
    -webkit-transform: scaleY(0);
            transform: scaleY(0);
  }
}
@-webkit-keyframes swing {
  from {
    -webkit-transform: rotate(-2deg);
            transform: rotate(-2deg);
  }
  to {
    -webkit-transform: rotate(2deg);
            transform: rotate(2deg);
  }
}
@keyframes swing {
  from {
    -webkit-transform: rotate(-2deg);
            transform: rotate(-2deg);
  }
  to {
    -webkit-transform: rotate(2deg);
            transform: rotate(2deg);
  }
}
@-webkit-keyframes glow {
  from {
    opacity: .2;
  }
  to {
    opacity: .1;
  }
}
@keyframes glow {
  from {
    opacity: .2;
  }
  to {
    opacity: .1;
  }
}

32