图片/图形

纯CSS3弹性卡通小怪物弹跳动画特效

阿里云


这是一款使用纯 CSS3 制作的非常有趣的卡通小怪物弹跳动画特效。该 CSS3 特效中有三个卡通小怪物,它们在不停的上下弹跳,并且各自的身体也带有一些弹性效果。

HTML 结构

每一个卡通小怪物的 HTML 结构都基本相似,使用嵌套<div>来构成怪物的身体,例如蓝色怪物的 HTML 结构为:

也想出现在这里?联系我们
创客主机
  1. <div class="item" id="blue">
  2.   <div class="chewing">
  3.     <div class="eye left"><span></span></div>
  4.     <div class="eye right"><span></span></div>
  5.     <div class="mounth"></div>
  6.     <div class="arm left"></div>
  7.     <div class="arm right"></div>
  8.   </div>
  9.   <div class="shadow"></div>
  10. </div>

CSS 样式

所有的小怪物都会执行一个 bounce 帧动画,该动画用于制作小怪物身体的弹性动画效果。

  1. .item {
  2.   width: 200px;
  3.   height: 200px;
  4.   bottom: 70px;
  5.   left: 50%;
  6.   margin-left: -50px;
  7.   -webkit-transform-origin: center bottom;
  8.   transform-origin: center bottom;
  9. }
  10. .item .chewing {
  11.   width: 100px;
  12.   height: 100px;
  13.   bottom: 0;
  14.   left: 50%;
  15.   margin-left: -50px;
  16.   box-shadow: inset 10px -6px 10px rgba(0, 0, 0, 0.1);
  17.   border-radius: 50% 50% 50% 50%/60% 60% 40% 40%;
  18.   -webkit-animation: bounce 0.6s ease-in-out infinite;
  19.   animation: bounce 0.6s ease-in-out infinite;
  20. }
  21. @keyframes bounce {
  22.   0% {
  23.     bottom: 0;
  24.   }
  25.   65% {
  26.     bottom: 8px;
  27.   }
  28.   100% {
  29.     bottom: 0;
  30.     border-radius: 49% 47% 42% 40%/60% 60% 40% 40%;
  31.   }
  32. }

arm-bounce 帧动画用于怪物手臂的缩放动画效果。mounth 帧动画是怪物的嘴巴动画效果。还有一个 shadow 帧动画的怪物的阴影动画效果。

  1. @keyframes arm-bounce {
  2.   0%, 100% {
  3.     bottom: 28px;
  4.   }
  5.   33% {
  6.     bottom: 23px;
  7.   }
  8.   40% {
  9.     -webkit-transform: scale(0.8);
  10.     transform: scale(0.8);
  11.   }
  12.   66% {
  13.     -webkit-transform: scale(1);
  14.     transform: scale(1);
  15.   }
  16. }
  17. @keyframes mounth {
  18.   0%, 100% {
  19.     height: 4px;
  20.     border-radius: 50% 50% 100% 100%;
  21.   }
  22.   50% {
  23.     height: 8px;
  24.     bottom: 17px;
  25.     border-radius: 30% 30% 100% 100%;
  26.   }
  27. }
  28. @keyframes shadow {
  29.   0%, 100% {
  30.     -webkit-transform: scaleX(1);
  31.     transform: scaleX(1);
  32.   }
  33.   50% {
  34.     -webkit-transform: scaleX(0.9);
  35.     transform: scaleX(0.9);
  36.   }
  37. }

完整的样式代码请参考下载文件。

纯 CSS3 弹性卡通小怪物弹跳动画特效

已有 369 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!