纯CSS3制作的恐龙动态动画代码

  • 1332
  • 0
  • 0

HTML部分代码:
  1. .optimizilla
  2.         .head
  3.                 .forehead
  4.                         .eye.eye-left
  5.                         .eye.eye-right
  6.                 .jaws
  7.                         .top-jaw
  8.                                 .nostril.nostril-left
  9.                                 .nostril.nostril-right
  10.                         .bottom-jaw
  11.                                 .teeth
  12.                                         - for(i=0; i<5; i++)
  13.                                                 .tooth
  14.         .body
  15.                 .spikes
  16.                         - for(i=0; i<4; i++)
  17.                                 .spike
  18.                 .tail
  19.                 .torso
  20.                         .hand.hand-left
  21.                                 .claws
  22.                         .hand.hand-right
  23.                                 .claws
  24.                         .leg.leg-left
  25.                                 .toe.toe-left
  26.                                 .toe.toe-middle
  27.                                 .toe.toe-right
  28.                         .leg.leg-right
  29.                                 .toe.toe-left
  30.                                 .toe.toe-middle
  31.                                 .toe.toe-right
复制代码
CSS部分代码:
  1. html, body{
  2.         background-color: #aad0ff;
  3.         width: 100%;
  4.         height: 100%;
  5. }

  6. .optimizilla{
  7.        
  8.         *{
  9.                 box-sizing: border-box;
  10.                 position: absolute;
  11.                 font-size: 0;
  12.         }
  13.        
  14.         $skin-color: #38B1B3;
  15.         $claw-color: #D1D4D4;
  16.         $spike-color: #FF7863;
  17.        
  18.         box-sizing: border-box;
  19.         position: absolute;
  20.         width: 426px;
  21.         height: 324px;
  22.     left: 0;
  23.     right: 0;
  24.     top: 0;
  25.     bottom: 0;
  26.     margin: auto;
  27.        
  28.         .head{
  29.                 width: 236px;
  30.                 height: 152px;
  31.                 top: 0;
  32.                 right: 0;
  33.                 text-align: left;
  34.                 z-index: 1;
  35.                 transform-origin: left bottom;
  36.                 animation: head 1s linear infinite;
  37.                
  38.                 .forehead{
  39.                         position: relative;
  40.                         display: inline-block;
  41.                         background-color: $skin-color;
  42.                         width: 135px;
  43.                         height: 43px;
  44.                         border-top-left-radius: 40px;
  45.                         border-top-right-radius: 40px;
  46.                        
  47.                         .eye{
  48.                                 position: relative;
  49.                                 display: inline-block;
  50.                                 margin-left: 22px;
  51.                                 margin-top: 12px;
  52.                                 width: 42px;
  53.                                 height: 31px;
  54.                                 background-color: #ffffff;
  55.                                 border-top-left-radius: 25px;
  56.                                 border-top-right-radius: 25px;
  57.                                 overflow: hidden;
  58.                                 z-index: 1;
  59.                                
  60.                                 &:before{
  61.                                         content: '';
  62.                                         position: absolute;
  63.                                         display: block;
  64.                                         height: 22px;
  65.                                         width: 18px;
  66.                                         background-color: #000000;
  67.                                         bottom: 0;
  68.                                         left: 9px;
  69.                                         border-top-left-radius: 10px;
  70.                                         border-top-right-radius: 10px;
  71.                                         animation: pupils 5s linear infinite;
  72.                                 }
  73.                                
  74.                                 &:after{
  75.                                         content: '';
  76.                                         position: absolute;
  77.                                         display: block;
  78.                                         height: 31px;
  79.                                         width: 42px;
  80.                                         background-color: darken($skin-color, 5%);
  81.                                         animation: blink 3s linear infinite;
  82.                                 }
  83.                                
  84.                                 &.eye-left{
  85.                                         margin-left: 22px;
  86.                                 }
  87.                                
  88.                                 &.eye-right{
  89.                                         margin-left: 10px;
  90.                                 }
  91.                                
  92.                         }
  93.                        
  94.                 }
  95.                
  96.                 .jaws{
  97.                         position: relative;
  98.                         width: 236px;
  99.                         height: 109px;
  100.                        
  101.                         .top-jaw{
  102.                                 position: relative;
  103.                                 width: 236px;
  104.                                 height: 49px;
  105.                                 background-color: $skin-color;
  106.                                 border-top-right-radius: 49px;
  107.                                 text-align: right;
  108.                                
  109.                                 .nostril{
  110.                                         position: relative;
  111.                                         width: 18px;
  112.                                         height: 18px;
  113.                                         border-radius: 50%;
  114.                                         background-color: #ffffff;
  115.                                         display: inline-block;
  116.                                         margin-top: 20px;
  117.                                        
  118.                                         &.nostril-right{
  119.                                                 margin-right: 20px;
  120.                                         }
  121.                                        
  122.                                         &.nostril-left{
  123.                                                 margin-right: 10px;
  124.                                         }
  125.                                        
  126.                                 }
  127.                                
  128.                         }
  129.                        
  130.                         .bottom-jaw{
  131.                                 position: relative;
  132.                                 height: 60px;
  133.                                 width: 225px;
  134.                                 border-bottom-left-radius: 60px;
  135.                                 border-bottom-right-radius: 60px;
  136.                                 background-color: $skin-color;               
  137.                                 text-align: right;
  138.                                 overflow: hidden;
  139.                                
  140.                                 .teeth{
  141.                                         position: relative;
  142.                                         display: inline-block;
  143.                                         width: 140px;
  144.                                         height: 25px;
  145.                                         overflow: hidden;
  146.                                         margin-right: 2px;
  147.                                        
  148.                                         .tooth{
  149.                                                 width: 20px;
  150.                                                 height: 25px;
  151.                                                 position: relative;
  152.                                                 display: inline-block;
  153.                                                 background-color: #ffffff;
  154.                                                 width: 0;
  155.                                                 height: 0;
  156.                                                 border-left: 14px solid $skin-color;
  157.                                                 border-right: 14px solid $skin-color;
  158.                                                 border-top: 25px solid #ffffff;
  159.                                         }
  160.                                        
  161.                                 }
  162.                                
  163.                         }
  164.                        
  165.                 }
  166.                
  167.         }
  168.        
  169.         .body{
  170.                
  171.                 .spikes{
  172.                         transform: rotate(-45deg);
  173.                         width: 350px;
  174.                         left: -37px;
  175.                     top: 117px;
  176.                         animation: spikes 1s linear infinite;
  177.                        
  178.                         .spike{
  179.                                 position: relative;
  180.                                 display: inline-block;
  181.                                 background-color: $spike-color;
  182.                                 width: 60px;
  183.                                 height: 60px;
  184.                                 margin: 0 6px;
  185.                                 vertical-align: bottom;
  186.                                
  187.                                 &:after{
  188.                                         content: '';
  189.                                         width: 42px;
  190.                                         height: 42px;
  191.                                         background-color: $spike-color;
  192.                                         position: absolute;
  193.                                         display: block;
  194.                                         transform: rotate(45deg);
  195.                                         top: -21px;
  196.                                     left: 9px;
  197.                                 }
  198.                                
  199.                                 &:first-child{
  200.                                         margin-left: 0;
  201.                                         height: 17px;
  202.                                     margin-bottom: 14px;
  203.                                 }
  204.                                
  205.                                 &:last-child{
  206.                                         margin-right: 0;
  207.                                        
  208.                                 }
  209.                                
  210.                         }
  211.                        
  212.                 }
  213.                
  214.                 .tail{
  215.                         left: 0;
  216.                         top: 175px;
  217.                         width: 0;
  218.                         height: 0;
  219.                         border-bottom: 110px solid $skin-color;
  220.                         border-left: 110px solid transparent;
  221.                         animation: torso 1s linear infinite;
  222.                 }
  223.                
  224.                 .torso{
  225.                         width: 230px;
  226.                         height: 220px;
  227.                         background-color: darken($skin-color, 10%);
  228.                         left: 75px;
  229.                         top: 65px;
  230.                         border-top-left-radius: 100%;
  231.                         animation: torso 1s linear infinite;
  232.                        
  233.                         .hand{
  234.                                 width: 68px;
  235.                                 height: 46px;
  236.                                 background-color: $skin-color;
  237.                                 top: 105px;
  238.                                 border-top-right-radius: 40px;
  239.                                 animation: hands 3s linear infinite;
  240.                                
  241.                                 &.hand-left{
  242.                                         left: 112px;
  243.                                 }
  244.                                
  245.                                 &.hand-right{
  246.                                         right: -40px;
  247.                                 }
  248.                                
  249.                                 .claws{
  250.                                         width: 68px;
  251.                                         height: 34px;
  252.                                         bottom: -34px;
  253.                                        
  254.                                         &:before, &:after{
  255.                                                 content: '';
  256.                                                 display: inline-block;
  257.                                                 width: 34px;
  258.                                                 height: 34px;
  259.                                                 background-color: $claw-color;
  260.                                                 border-bottom-right-radius: 100%;
  261.                                                 bottom: 0px;
  262.                                         }
  263.                                        
  264.                                 }
  265.                                
  266.                         }
  267.                
  268.                         .leg{
  269.                                 top: 204px;
  270.                                 width: 115px;
  271.                                 height: 55px;
  272.                                 background-color: $skin-color;
  273.                                 border-top-left-radius: 55px;
  274.                                 border-top-right-radius: 55px;
  275.                                 animation: legs 1s linear infinite;
  276.                                
  277.                                 &.leg-right{
  278.                                         left: 172px;
  279.                                 }
  280.                                
  281.                                 &.leg-left{
  282.                                         left: 20px;
  283.                                 }
  284.                                
  285.                                 .toe{
  286.                                         width: 44px;
  287.                                         height: 20px;
  288.                                         background-color: $claw-color;
  289.                                         bottom: 0;
  290.                                         border-top-left-radius: 20px;
  291.                                         border-top-right-radius: 20px;
  292.                                        
  293.                                         &.toe-left{
  294.                                                 left: 25px;
  295.                                                 border-top: 6px solid $skin-color;
  296.                                                 border-right: 6px solid $skin-color;
  297.                                                 z-index: 3;
  298.                                                 width: 50px;
  299.                                                 height: 26px;
  300.                                                 border-top-left-radius: 26px;
  301.                                                 border-top-right-radius: 26px;
  302.                                         }
  303.                                        
  304.                                         &.toe-middle{
  305.                                                 left: 61px;
  306.                                                 z-index: 2;
  307.                                                 width: 50px;
  308.                                                 height: 26px;
  309.                                                 border-top: 6px solid $skin-color;
  310.                                                 border-right: 6px solid $skin-color;
  311.                                                 border-top-left-radius: 26px;
  312.                                                 border-top-right-radius: 26px;
  313.                                         }
  314.                                        
  315.                                         &.toe-right{
  316.                                                 left: 86px;
  317.                                                 z-index: 1;
  318.                                         }
  319.                                        
  320.                                 }
  321.                                
  322.                         }
  323.                        
  324.                 }
  325.                
  326.         }
  327.        
  328.         @keyframes head{
  329.                 0%{
  330.                         transform: rotate(0);
  331.                 }
  332.                 50%{
  333.                         transform: rotate(2deg);
  334.                 }
  335.                 100%{
  336.                         transform: rotate(0);
  337.                 }
  338.         }
  339.        
  340.         @keyframes blink{
  341.                 0%{
  342.                         transform: translateY(-70%);
  343.                 }
  344.                 30%{
  345.                         transform: translateY(-70%);
  346.                 }
  347.                 32%{
  348.                         transform: translateY(0);
  349.                 }
  350.                 34%{
  351.                         transform: translateY(-70%);
  352.                 }
  353.                 64%{
  354.                         transform: translateY(-70%);
  355.                 }
  356.                 66%{
  357.                         transform: translateY(0);
  358.                 }
  359.                 68%{
  360.                         transform: translateY(-70%);
  361.                 }
  362.                 100%{
  363.                         transform: translateY(-70%);
  364.                 }
  365.         }
  366.        
  367.         @keyframes hands{
  368.                 0%{
  369.                         transform: rotate(0) translateX(0);
  370.                 }
  371.                 10%{
  372.                         transform: rotate(-140deg) translateX(0);
  373.                 }
  374.                 15%{
  375.                         transform: rotate(-70deg) translateX(40px);
  376.                 }
  377.                 20%{
  378.                         transform: rotate(0) translateX(0);
  379.                 }
  380.                 100%{
  381.                         transform: rotate(0) translateX(0);
  382.                 }
  383.         }
  384.        
  385.         @keyframes torso{
  386.                 0%{
  387.                         transform: translateY(0);
  388.                 }
  389.                 50%{
  390.                         transform: translateY(5px);
  391.                 }
  392.                 100%{
  393.                         transform: translateY(0);
  394.                 }
  395.         }
  396.        
  397.         @keyframes spikes{
  398.                 0%{
  399.                         transform: rotate(-45deg) translateY(0);
  400.                 }
  401.                 50%{
  402.                         transform: rotate(-45deg) translateY(6px);
  403.                 }
  404.                 100%{
  405.                         transform: rotate(-45deg) translateY(0);
  406.                 }
  407.         }
  408.        
  409.         @keyframes legs{
  410.                 0%{
  411.                         transform: translateY(0);
  412.                 }
  413.                 50%{
  414.                         transform: translateY(-5px);
  415.                 }
  416.                 100%{
  417.                         transform: translateY(0);
  418.                 }
  419.         }
  420.        
  421.         @keyframes pupils{
  422.                 0%{
  423.                         transform: translateX(0);
  424.                 }
  425.                 20%{
  426.                         transform: translateX(0);
  427.                 }
  428.                 25%{
  429.                         transform: translateX(8px);
  430.                 }
  431.                 40%{
  432.                         transform: translateX(8px);
  433.                 }
  434.                 45%{
  435.                         transform: translateX(0);
  436.                 }
  437.                 100%{
  438.                         transform: translateX(0);
  439.                 }
  440.         }
  441.        
  442. }
复制代码


纯CSS3制作的恐龙动态动画代码
  • Sergei 刚刚下载了一个素材
  • Komorebii 刚刚下载了一个素材
  • qq游Yj6 刚刚下载了一个素材
  • 妙啊! 刚刚下载了一个素材
  • Monday 刚刚下载了一个素材
  • qqcandyN1L 刚刚下载了一个素材
  • 现代化 刚刚下载了一个素材
  • 我是小白 刚刚下载了一个素材
  • 44444 刚刚下载了一个素材
  • WANGHAORAN 刚刚下载了一个素材
  • Xmonkey 刚刚下载了一个素材
  • NACL 刚刚下载了一个素材
  • 孟旭 刚刚下载了一个素材
  • 聂儿 刚刚下载了一个素材
  • Famiglistimo 刚刚下载了一个素材
分享者:
分享者头像
xiaozhi
热门素材推荐
HTML素材网,HTML5模板,网页特效 微信公众账号二维码 淘宝店铺地址二维码
Copyright©2024  素材8  Powered by 智伙伴科技
   鲁ICP备14029286号-5 鲁公网安备37060202001967号
返回顶部返回顶部
发布主题