一款纯css3制作的2015年元旦雪人动画特效教程


Posted in HTML / CSS onDecember 29, 2014

在圣诞节或者是元旦的时候,爱编程小编给大家分享一款纯css3实现的雪人动画特效。该实例实现一个雪人跳动的特效,效果图如下:

一款纯css3制作的2015年元旦雪人动画特效教程

实现的代码。

html代码:

XML/HTML Code复制内容到剪贴板
  1. <span class="text">lolwut<small>-@rsmswlln</small></span>  
  2.    <div class="body">  
  3.        <div class="hat">  
  4.            <div class="ribbon">  
  5.            </div>  
  6.        </div>  
  7.        <div class="face">  
  8.        </div>  
  9.        <div class="scarf">  
  10.        </div>  
  11.        <div class="right-arm">  
  12.            <div class="hand">  
  13.            </div>  
  14.        </div>  
  15.        <div class="left-arm">  
  16.            <div class="hand">  
  17.            </div>  
  18.        </div>  
  19.    </div>  
  20.    <div class="puddle">  
  21.    </div>  

css代码:

CSS Code复制内容到剪贴板
  1. body {   
  2.   background#c0392b;   
  3. }   
  4. .body {   
  5.   width250px;   
  6.   height250px;   
  7.   background#ffffff;   
  8.   border-radius: 50%;   
  9.   box-shadow: inset -20px -5px 35px rgba(0, 0, 0, 0.2);   
  10.   positionabsolute;   
  11.   rightright: 0;   
  12.   left: 0;   
  13.   margin300px auto;   
  14.   animation: jump 1s infinite;   
  15. }   
  16. .body:before {   
  17.   z-index: 2;   
  18.   content"";   
  19.   width180px;   
  20.   height180px;   
  21.   background#ffffff;   
  22.   border-radius: 50%;   
  23.   box-shadow: inset -10px -5px 10px rgba(0, 0, 0, 0.2);   
  24.   positionrelative;   
  25.   displayinline-block;   
  26.   top: -120px;   
  27.   left25px;   
  28. }   
  29. .body:after {   
  30.   content"";   
  31.   width140px;   
  32.   height140px;   
  33.   background#ffffff;   
  34.   border-radius: 50%;   
  35.   box-shadow: inset -10px -5px 10px rgba(0, 0, 0, 0.2);   
  36.   positionrelative;   
  37.   displayinline-block;   
  38.   top: -400px;   
  39.   left20px;   
  40. }   
  41. .body > .hat {   
  42.   width200px;   
  43.   height15px;   
  44.   border-radius: 50%;   
  45.   background-color#111111;   
  46.   positionabsolute;   
  47.   z-index: 4;   
  48.   top: -200px;   
  49.   left: -15px;   
  50. }   
  51. .body > .hat:before {   
  52.   content"";   
  53.   width100px;   
  54.   height65px;   
  55.   background-color#111111;   
  56.   displayinline-block;   
  57.   positionrelative;   
  58.   top: -55px;   
  59.   left51px;   
  60. }   
  61. .body > .hat:after {   
  62.   z-index: 5;   
  63.   content"";   
  64.   displayinline-block;   
  65.   positionrelative;   
  66.   top: -145px;   
  67.   left51px;   
  68.   width100px;   
  69.   height5px;   
  70.   border-radius: 50%;   
  71.   background-color#2b2b2b;   
  72. }   
  73. .body > .hat > .ribbon {   
  74.   height10px;   
  75.   width100px;   
  76.   background-color#6d2018;   
  77.   positionrelative;   
  78.   top: -90px;   
  79.   left51px;   
  80.   z-index: 6;   
  81. }   
  82. .body > .face {   
  83.   z-index: 3;   
  84.   width12px;   
  85.   height12px;   
  86.   background-color#2c3e50;   
  87.   border-radius: 50%;   
  88.   positionabsolute;   
  89.   top: -170px;   
  90.   left38px;   
  91. }   
  92. .body > .face:before {   
  93.   content"";   
  94.   background-colortransparent;   
  95.   displayinline-block;   
  96.   positionrelative;   
  97.   top30px;   
  98.   left: -45px;   
  99.   transform: rotate(-15deg);   
  100.   border-top12px solid transparent;   
  101.   border-bottom12px solid transparent;   
  102.   border-right40px solid #e67e22;   
  103. }   
  104. .body > .face:after {   
  105.   content"";   
  106.   background-colortransparent;   
  107.   displayinline-block;   
  108.   positionrelative;   
  109.   top: 0;   
  110.   left: -46px;   
  111.   transform: rotate(-15deg);   
  112.   border-top12px solid transparent;   
  113.   border-right40px solid #bf6516;   
  114. }   
  115. .body > .scarf {   
  116.   z-index: 3;   
  117.   width150px;   
  118.   height30px;   
  119.   background-color#2980b9;   
  120.   positionabsolute;   
  121.   top: -110px;   
  122.   left25px;   
  123.   transform: rotate(-15deg);   
  124.   border-radius: 20%;   
  125. }   
  126. .body > .scarf:after {   
  127.   content"";   
  128.   width75px;   
  129.   height30px;   
  130.   background-color#2980b9;   
  131.   displayinline-block;   
  132.   positionrelative;   
  133.   top16px;   
  134.   left80px;   
  135.   transform: rotate(85deg);   
  136.   border-radius: 20%;   
  137. }   
  138. .body > .left-arm,   
  139. .body .rightright-arm {   
  140.   z-index: 7;   
  141.   width100px;   
  142.   height6px;   
  143.   background-color#825a2c;   
  144.   positionabsolute;   
  145.   top10px;   
  146.   left: -20px;   
  147.   transform: rotate(-15deg);   
  148.   animation: rub-rightright 0.5s infinite;   
  149. }   
  150. .body > .left-arm > .hand,   
  151. .body .rightright-arm > .hand {   
  152.   width25px;   
  153.   height6px;   
  154.   background-color#825a2c;   
  155.   positionabsolute;   
  156.   top: -32px;   
  157.   left: -60px;   
  158.   transform: rotate(75deg);   
  159. }   
  160. .body > .left-arm:after,   
  161. .body .rightright-arm:after {   
  162.   content"";   
  163.   width75px;   
  164.   height6px;   
  165.   background-color#a87439;   
  166.   displayinline-block;   
  167.   positionrelative;   
  168.   top: -24px;   
  169.   left: -70px;   
  170.   transform: rotate(25deg);   
  171. }   
  172. .body > .left-arm.left-arm,   
  173. .body .rightright-arm.left-arm {   
  174.   background-color#a87439;   
  175.   animation: rub-left 0.5s infinite;   
  176.   top: -15px;   
  177.   z-index: 1;   
  178. }   
  179. .body > .left-arm.left-arm > .hand,   
  180. .body .rightright-arm.left-arm > .hand {   
  181.   background-color#a87439;   
  182.   top: -14px;   
  183.   transform: rotate(45deg);   
  184. }   
  185. .body > .left-arm.left-arm:after,   
  186. .body .rightright-arm.left-arm:after {   
  187.   background-color#825a2c;   
  188.   transform: rotate(5deg);   
  189.   top: -12px;   
  190.   left: -74px;   
  191. }   
  192. .puddle {   
  193.   z-index: -1;   
  194.   width200px;   
  195.   height100px;   
  196.   background#2980b9;   
  197.   border-radius: 50%;   
  198.   positionabsolute;   
  199.   rightright: 0;   
  200.   left: -50px;   
  201.   margin500px auto;   
  202. }   
  203. .puddle:after {   
  204.   content"";   
  205.   width120px;   
  206.   height80px;   
  207.   displayinline-block;   
  208.   border-radius: 50%;   
  209.   left150px;   
  210.   positionrelative;   
  211.   background-color#2980b9;   
  212. }   
  213. .text {   
  214.   text-aligncenter;   
  215.   font-family'Lobster'cursive;   
  216.   font-size74px;   
  217.   displayinline-block;   
  218.   transform: rotate(-15deg);   
  219.   positionabsolute;   
  220.   margin50px 30px;   
  221.   color#ffffff;   
  222.   text-shadow3px 3px 2px rgba(0, 0, 0, 0.5);   
  223. }   
  224. .text > small {   
  225.   font-size20px;   
  226.   displayblock;   
  227. }   
  228. @keyframes rub-left {   
  229.   0% {   
  230.     margin-left0px;   
  231.     margin-top: 0;   
  232.   }   
  233.   50% {   
  234.     margin-left5px;   
  235.     margin-top1px;   
  236.   }   
  237.   100% {   
  238.     margin-left0px;   
  239.     margin-top: 0;   
  240.   }   
  241. }   
  242. @keyframes rub-rightright {   
  243.   0% {   
  244.     margin-left4px;   
  245.   }   
  246.   50% {   
  247.     margin-left0px;   
  248.   }   
  249.   100% {   
  250.     margin-left4px;   
  251.   }   
  252. }   
  253. @keyframes jump {   
  254.   0% {   
  255.     margin300px auto;   
  256.   }   
  257.   40% {   
  258.     margin250px auto;   
  259.   }   
  260.   80% {   
  261.     margin300px auto;   
  262.   }   
  263. }  
HTML / CSS 相关文章推荐
浅析rem和em和px vh vw和% 移动端长度单位
Apr 28 HTML / CSS
html5定制表单_动力节点Java学院整理
Jul 11 HTML / CSS
H5 canvas中width、height和style的宽高区别详解
Nov 02 HTML / CSS
HTML5之SVG 2D入门7—SVG元素的重用与引用
Jan 30 HTML / CSS
html5的画布canvas——画出弧线、旋转的图形实例代码+效果图
Jun 09 HTML / CSS
HTML5 Canvas自定义圆角矩形与虚线示例代码
Aug 02 HTML / CSS
巧用HTML5给按钮背景设计不同的动画简单实例
Aug 09 HTML / CSS
div与span之间的区别与使用介绍
Dec 06 HTML / CSS
CSS3实现指纹特效代码
Mar 17 HTML / CSS
常用的文件对应的MIME类型汇总
Apr 26 HTML / CSS
解决flex布局中子项目尺寸不受flex-shrink限制
May 11 HTML / CSS
box-shadow单边阴影的实现
May 21 HTML / CSS
一款利用css3的鼠标经过动画显示详情特效的实例教程
Dec 29 #HTML / CSS
纯css3实现照片墙效果
Dec 26 #HTML / CSS
纯css3实现走马灯效果
Dec 26 #HTML / CSS
纯CSS3实现的阴影效果
Dec 24 #HTML / CSS
使用CSS3实现圆角,阴影,透明
Dec 23 #HTML / CSS
纯css3实现的鼠标悬停动画按钮
Dec 23 #HTML / CSS
css3实现3D色子翻转特效
Dec 23 #HTML / CSS
You might like
深入phpMyAdmin的安装与配置的详细步骤
2013/05/07 PHP
PHP防止表单重复提交的几种常用方法汇总
2014/08/19 PHP
JS限制上传图片大小不使用控件在本地实现
2012/12/19 Javascript
自己编写的类似JS的trim方法
2013/10/09 Javascript
javascript从右边截取指定字符串的三种实现方法
2013/11/29 Javascript
js常用自定义公共函数汇总
2014/01/15 Javascript
node.js中的fs.lchown方法使用说明
2014/12/16 Javascript
表单input项使用label同时引用Bootstrap库导致input点击效果区增大问题
2016/10/11 Javascript
Vue中的数据监听和数据交互案例解析
2017/07/12 Javascript
基于AngularJS的拖拽文件上传的实例代码
2017/07/15 Javascript
教你5分钟学会用requirejs(必看篇)
2017/07/25 Javascript
jquery tmpl模板(实例讲解)
2017/09/02 jQuery
JS实现多物体运动的方法详解
2018/01/23 Javascript
Vue 组件封装 并使用 NPM 发布的教程
2018/09/30 Javascript
vue实现下拉加载其实没那么复杂
2019/08/13 Javascript
Node.js API详解之 tty功能与用法实例分析
2020/04/27 Javascript
jQuery实现增删改查
2020/12/22 jQuery
[04:28]DOTA2亚洲邀请赛小组赛第五日 TOP10精彩集锦
2015/02/03 DOTA
python利用elaphe制作二维条形码实现代码
2012/05/25 Python
深入讲解Python函数中参数的使用及默认参数的陷阱
2016/03/13 Python
Python 实现将numpy中的nan和inf,nan替换成对应的均值
2020/06/08 Python
Win10下用Anaconda安装TensorFlow(图文教程)
2020/06/18 Python
详细分析Python collections工具库
2020/07/16 Python
如何在Anaconda中打开python自带idle
2020/09/21 Python
Python语言编写智力问答小游戏功能
2020/10/13 Python
纯CSS3大转盘抽奖示例代码(响应式、可配置)
2017/01/13 HTML / CSS
HTML5新增加的功能详解
2016/09/05 HTML / CSS
three.js模拟实现太阳系行星体系功能
2019/09/03 HTML / CSS
设计师家具购买和委托在线市场:Viyet
2016/11/16 全球购物
STRATHBERRY苏贝瑞包包官网:西班牙高级工匠手工打造
2020/11/10 全球购物
在求职信中如何凸显个人优势
2013/10/30 职场文书
总结表彰大会主持词
2014/03/26 职场文书
小学生暑假家长评语
2014/04/17 职场文书
煤矿安全演讲稿
2014/05/09 职场文书
PostgreSQL13基于流复制搭建后备服务器的方法
2022/01/18 PostgreSQL
Spring Boot优化后启动速度快到飞起技巧示例
2022/07/23 Java/Android