Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 在线亚洲激情,色婷婷5月精品久久久久,好男人社区www的视频免费

          整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          css - animation 常用的動畫效果

          近項目需要,寫一些動畫效果,下面對animation的知識鞏固了一下,希望可以幫助到有需要的小伙伴們。

          animation

          animation-name 需要綁定到選擇器的 keyframe 名稱


          animation-duration 完成動畫所需要的時間


          animation-delay 設置延長時間


          animation-timing-function 動畫的運動速度


          • linear 動畫從頭到尾的速度是相同的。
          • ease 默認。動畫以低速開始,然后加快,在結束前變慢。
          • ease-in 動畫以低速開始。
          • ease-out 動畫以低速結束。
          • ease-in-out 動畫以低速開始和結束。
          • cubic-bezier(n,n,n,n) 在 cubic-bezier 函數中自己的值。可能的值是從 0 到 1 的數值。

          animation-iteration-count 動畫播放的次數


          infinite 規定動畫應該無限次播放。

          animation-direction 輪流反向播放動畫


          • normal 默認值。動畫應該正常播放。
          • alternate 動畫應該輪流反向播放。

          這個先介紹到這里吧,下面分享幾個demo!!!

          1、animation1


          <div class="spinner">
           <div class="rect1"></div>
           <div class="rect2"></div>
           <div class="rect3"></div>
           <div class="rect4"></div>
           <div class="rect5"></div>
          </div>
          <style>
          .spinner {
           margin: 100px auto;
           width: 50px;
           height: 60px;
           text-align: center;
           font-size: 10px;
          }
           
          .spinner > div {
           background-color: #67CF22;
           height: 100%;
           width: 6px;
           display: inline-block;
           
           -webkit-animation: stretchdelay 1.2s infinite ease-in-out;
           animation: stretchdelay 1.2s infinite ease-in-out;
          }
           
          .spinner .rect2 {
           -webkit-animation-delay: -1.1s;
           animation-delay: -1.1s;
          }
           
          .spinner .rect3 {
           -webkit-animation-delay: -1.0s;
           animation-delay: -1.0s;
          }
           
          .spinner .rect4 {
           -webkit-animation-delay: -0.9s;
           animation-delay: -0.9s;
          }
           
          .spinner .rect5 {
           -webkit-animation-delay: -0.8s;
           animation-delay: -0.8s;
          }
           
          @-webkit-keyframes stretchdelay {
           0%, 40%, 100% { -webkit-transform: scaleY(0.4) } 
           20% { -webkit-transform: scaleY(1.0) }
          }
           
          @keyframes stretchdelay {
           0%, 40%, 100% {
           transform: scaleY(0.4);
           -webkit-transform: scaleY(0.4);
           } 20% {
           transform: scaleY(1.0);
           -webkit-transform: scaleY(1.0);
           }
          }
          </style>
          
          <div class="spinner"></div>
          <style>
          .spinner {
           width: 60px;
           height: 60px;
           background-color: #67CF22;
           
           margin: 100px auto;
           -webkit-animation: rotateplane 1.2s infinite ease-in-out;
           animation: rotateplane 1.2s infinite ease-in-out;
          }
           
          @-webkit-keyframes rotateplane {
           0% { -webkit-transform: perspective(120px) }
           50% { -webkit-transform: perspective(120px) rotateY(180deg) }
           100% { -webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg) }
          }
           
          @keyframes rotateplane {
           0% {
           transform: perspective(120px) rotateX(0deg) rotateY(0deg);
           -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg)
           } 50% {
           transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
           -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg)
           } 100% {
           transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
           -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
           }
          }
          </style>
          
          <div class="spinner">
           <div class="double-bounce1"></div>
           <div class="double-bounce2"></div>
          </div>
          <style>
          .spinner {
           width: 60px;
           height: 60px;
           
           position: relative;
           margin: 100px auto;
          }
           
          .double-bounce1, .double-bounce2 {
           width: 100%;
           height: 100%;
           border-radius: 50%;
           background-color: #67CF22;
           opacity: 0.6;
           position: absolute;
           top: 0;
           left: 0;
           
           -webkit-animation: bounce 2.0s infinite ease-in-out;
           animation: bounce 2.0s infinite ease-in-out;
          }
           
          .double-bounce2 {
           -webkit-animation-delay: -1.0s;
           animation-delay: -1.0s;
          }
           
          @-webkit-keyframes bounce {
           0%, 100% { -webkit-transform: scale(0.0) }
           50% { -webkit-transform: scale(1.0) }
          }
           
          @keyframes bounce {
           0%, 100% {
           transform: scale(0.0);
           -webkit-transform: scale(0.0);
           } 50% {
           transform: scale(1.0);
           -webkit-transform: scale(1.0);
           }
          }
          </style>
          
          <div class="spinner">
           <div class="dot1"></div>
           <div class="dot2"></div>
          </div>
          <style>
          .spinner {
           margin: 100px auto;
           width: 90px;
           height: 90px;
           position: relative;
           text-align: center;
           
           -webkit-animation: rotate 2.0s infinite linear;
           animation: rotate 2.0s infinite linear;
          }
           
          .dot1, .dot2 {
           width: 60%;
           height: 60%;
           display: inline-block;
           position: absolute;
           top: 0;
           background-color: #67CF22;
           border-radius: 100%;
           
           -webkit-animation: bounce 2.0s infinite ease-in-out;
           animation: bounce 2.0s infinite ease-in-out;
          }
           
          .dot2 {
           top: auto;
           bottom: 0px;
           -webkit-animation-delay: -1.0s;
           animation-delay: -1.0s;
          }
           
          @-webkit-keyframes rotate { 100% { -webkit-transform: rotate(360deg) }}
          @keyframes rotate { 100% { transform: rotate(360deg); -webkit-transform: rotate(360deg) }}
           
          @-webkit-keyframes bounce {
           0%, 100% { -webkit-transform: scale(0.0) }
           50% { -webkit-transform: scale(1.0) }
          }
           
          @keyframes bounce {
           0%, 100% {
           transform: scale(0.0);
           -webkit-transform: scale(0.0);
           } 50% {
           transform: scale(1.0);
           -webkit-transform: scale(1.0);
           }
          }
          </style>
          
          <div class="spinner">
           <div class="bounce1"></div>
           <div class="bounce2"></div>
           <div class="bounce3"></div>
          </div>
          <style>
          .spinner {
           margin: 100px auto 0;
           width: 150px;
           text-align: center;
          }
           
          .spinner > div {
           width: 30px;
           height: 30px;
           background-color: #67CF22;
           
           border-radius: 100%;
           display: inline-block;
           -webkit-animation: bouncedelay 1.4s infinite ease-in-out;
           animation: bouncedelay 1.4s infinite ease-in-out;
           /* Prevent first frame from flickering when animation starts */
           -webkit-animation-fill-mode: both;
           animation-fill-mode: both;
          }
           
          .spinner .bounce1 {
           -webkit-animation-delay: -0.32s;
           animation-delay: -0.32s;
          }
           
          .spinner .bounce2 {
           -webkit-animation-delay: -0.16s;
           animation-delay: -0.16s;
          }
           
          @-webkit-keyframes bouncedelay {
           0%, 80%, 100% { -webkit-transform: scale(0.0) }
           40% { -webkit-transform: scale(1.0) }
          }
           
          @keyframes bouncedelay {
           0%, 80%, 100% {
           transform: scale(0.0);
           -webkit-transform: scale(0.0);
           } 40% {
           transform: scale(1.0);
           -webkit-transform: scale(1.0);
           }
          }
          </style>
          

          喜歡前端的小伙伴們可以在評論區留言,尋找和小馮童鞋一樣熱愛前端的友人,讓我們一起玩轉前端的世界!

          SS3 Animations

          1 @keyframes屬性

          @keyframes 動畫名稱{關鍵幀持續時間% {css樣式;}}

          @keyframes myanimation
          {
              0% {top:0px;background-color:#0000cc;}
              50% {top:100px;background-color;#339900;}
              100% {top:0px;background-color:#330000;}
          }

          2 animation屬性

          animation: name duration timing-function delay iteration-count direction;

          animation-name 規定需要綁定到選擇器的 keyframe 名稱。。

          animation-duration 規定完成動畫所花費的時間, 以秒或毫秒計。

          animation-timing-function 規定動畫的速度曲線。

          linear 動畫從頭到尾的速度是相同的。

          ease 默認。動畫以低速開始, 然后加快, 在結束前變慢。

          ease-in 動畫以低速開始。

          ease-out 動畫以低速結束。

          ease-in-out 動畫以低速開始和結束。

          cubic-bezier(n,n,n,n) 在 cubic-bezier 函數中自己的值。可能的值是從 0 到 1 的數值。 參考地址: http://cubic-bezier.com/#.17,.67,.83,.67

          animation-delay 規定在動畫開始之前的延遲。以秒或毫秒計, 默認值是 0。

          animation-iteration-count 規定動畫應該播放的次數。

          n 定義動畫播放次數的數值。

          infinite 規定動畫應該無限次播放。

          animation-direction 規定是否應該輪流反向播放動畫。

          normal 默認值。動畫應該正常播放。

          alternate 動畫應該輪流反向播放。

          使用方法一: from...to...

          <!DOCTYPE html>
          <html>
          <head>
          <meta charset="UTF-8">
          <title></title>
          <style type="text/css">
          *{
              margin: 0;
              padding: 0;
          }
          div{
              width: 100px;
              height: 100px;
              background-color: orange;
          
          }
          
          /*div:hover{
          width: 800px;
          }*/
          /*@keyframes 動畫名{
          from{
          動畫第一步(這里你可以不寫他會繼承上面的)
          }
          to{
          動畫最后一步
          }
          }*/
          /*動畫聲明*/
          @keyframes widthChange{
          /*from{
          width: 100px;
          }*/
          to{
          width: 800px;
          }
          }
          div{
              /*animation: 動畫名稱 過渡總時長;*/
              animation: widthChange 1s;
          }
          </style>
          </head>
          <body>
          <div></div>
          </body>
          </html>

          使用方法二: 百分比

          <!DOCTYPE html>
          <html>
          <head>
          <meta charset="UTF-8">
          <title></title>
          <style type="text/css">
          *{
          margin: 0;
          padding: 0;
          }
          div{
          width: 100px;
          height: 100px;
          background-color: orange;
          position: absolute;
          left: 0;
          top: 0;
          }
          
          /*動畫聲明*/
          @keyframes positionChange{
              /*from{
              left: 0;
              }
              to{
              left: 800px;
              }*/
              /*百分數評分的的過渡總時長*/
              0%{
              left: 0;
              top: 0;
              }
              50%{
              left: 800px;
              top: 0;
              }
              100%{
              left: 800px;
              top: 500px;
              }
          }
          div{
              /*animation: 動畫名稱 過渡總時長;*/
              animation: positionChange 10s;
          }
          </style>
          </head>
          <body>
          <div></div>
          </body>
          </html>

          使用方法三: animation參數格式

          <!DOCTYPE html>
          <html>
          <head>
          <meta charset="UTF-8">
          <title></title>
          <style type="text/css">
          *{
              margin: 0;
              padding: 0;
          }
          div{
              width: 100px;
              height: 100px;
              background-color: orange;
          
          }
          @keyframes widthChange{
              to{
              width: 800px;
              }
          }
          div{
              /*
              * 動畫名稱
              * 動畫總時長s ms
              * 動畫形式ease ease-in ease-out ease-in-out linear 貝塞爾曲線、
              * 延遲時間s ms
              * 循環次數①阿拉伯數字②infinite(無限次)
              * 停留到最后一幀forwards
              * 反向播放動畫alternate(來回當做2次處理) normal 正常
              *
              * */
              animation: widthChange 5s;
          }
          div:hover{
          /*動畫停止*/
          animation-play-state: paused
          }
          </style>
          </head>
          <body>
          <div></div>
          </body>
          </html>

          建立3D場景

          transform-style 屬性規定如何在 3D 空間中呈現被嵌套的元素。

          注釋:該屬性必須與 transform 屬性一同使用。

          flat 子元素將不保留其 3D 位置。

          preserve-3d 子元素將保留其 3D 位置。

          transform-style: flat|preserve-3d;

          perspective 屬性定義 3D 元素距視圖的距離, 以像素計。該屬性允許您改變 3D 元素查看 3D 元素的視圖。

          當為元素定義 perspective 屬性時, 其子元素會獲得透視效果, 而不是元素本身。

          注釋:perspective 屬性只影響 3D 轉換元素。

          perspective: number|none;

          景深:

          perspective是設置3d效果的景深, 通俗來說就是設置你的眼睛與這個3d元素的距離。

          而生活經驗告訴我們, 你從遠處和近處分別觀察同一個物體(比如正方形)時, 其3d效果肯定是不同的。

          perspective-origin 屬性定義 3D 元素所基于的 X 軸和 Y 軸。該屬性允許您改變 3D 元素的底部位置。

          當為元素定義 perspective-origin 屬性時, 其子元素會獲得透視效果, 而不是元素本身。

          注釋:該屬性必須與 perspective 屬性一同使用, 而且只影響 3D 轉換元素。

          <!DOCTYPE html>
          <html lang="zh">
          <head>
          <meta charset="UTF-8" />
          <meta name="viewport" content="width=device-width, initial-scale=1.0" />
          <meta http-equiv="X-UA-Compatible" content="ie=edge" />
          <title>Document</title>
          <style type="text/css">
          *{
              margin: 0;
              padding: 0;
              list-style: none;
          }
          div{
              width: 300px;
              height: 220px;
              margin: 100px auto;
              border: 1px solid #000;
          
              transform-style: preserve-3d;
              perspective: 800px;
          
              /*景深基點基本上沒人改*/
              perspective-origin: left top;
          }
          img{
              width: 100%;
              display: block;
              transition: 1s;
              }
              div:hover>img{
              transform: rotateX(-45deg);
          }
          </style>
          </head>
          <body>
          <div>
          <img src="img/薛凱琪.jpg"/>
          </div>
          </body>
          </html>

          backface-visibility 屬性定義當元素不面向屏幕時是否可見。

          如果在旋轉元素不希望看到其背面時, 該屬性很有用。

          背面隱藏

          言:每當過節的時候,女朋友就抱怨我總是忘記給她買花,說程序不懂浪漫,這不我準備了幾款愛心動畫特效,打算當面向她表達一下。

          第一款:html5通過canvas實現浪漫告白愛心動畫特效

          寓意:告白無須多么華麗的語言,一顆顆小的愛心匯聚成一顆真心,讓你的另一半感受到濃濃的愛意。

          代碼難度系數★★★

          新建index.html,復制以下代碼保存在瀏覽器中打開即可。

          <!doctype html>
          <html>
          <head>
          <meta charset="utf-8">
          <title>canvas 心</title>
          
          <style>
          html, body {
            height: 100%;
            padding: 0;
            margin: 0;
            background: #000;
          }
          canvas {
            position: absolute;
            width: 100%;
            height: 100%;
          }</style>
          </head>
          <body>
          
          <canvas id="pinkboard"></canvas>
          
          <script>
          /*
           * Settings
           */
          var settings = {
            particles: {
              length:   500, // maximum amount of particles
              duration:   2, // particle duration in sec
              velocity: 100, // particle velocity in pixels/sec
              effect: -0.75, // play with this for a nice effect
              size:      30, // particle size in pixels
            },
          };
          
          /*
           * RequestAnimationFrame polyfill by Erik M?ller
           */
          (function(){var b=0;var c=["ms","moz","webkit","o"];for(var a=0;a<c.length&&!window.requestAnimationFrame;++a){window.requestAnimationFrame=window[c[a]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[c[a]+"CancelAnimationFrame"]||window[c[a]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(h,e){var d=new Date().getTime();var f=Math.max(0,16-(d-b));var g=window.setTimeout(function(){h(d+f)},f);b=d+f;return g}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(d){clearTimeout(d)}}}());
          
          /*
           * Point class
           */
          var Point = (function() {
            function Point(x, y) {
              this.x = (typeof x !== 'undefined') ? x : 0;
              this.y = (typeof y !== 'undefined') ? y : 0;
            }
            Point.prototype.clone = function() {
              return new Point(this.x, this.y);
            };
            Point.prototype.length = function(length) {
              if (typeof length == 'undefined')
                return Math.sqrt(this.x * this.x + this.y * this.y);
              this.normalize();
              this.x *= length;
              this.y *= length;
              return this;
            };
            Point.prototype.normalize = function() {
              var length = this.length();
              this.x /= length;
              this.y /= length;
              return this;
            };
            return Point;
          })();
          
          /*
           * Particle class
           */
          var Particle = (function() {
            function Particle() {
              this.position = new Point();
              this.velocity = new Point();
              this.acceleration = new Point();
              this.age = 0;
            }
            Particle.prototype.initialize = function(x, y, dx, dy) {
              this.position.x = x;
              this.position.y = y;
              this.velocity.x = dx;
              this.velocity.y = dy;
              this.acceleration.x = dx * settings.particles.effect;
              this.acceleration.y = dy * settings.particles.effect;
              this.age = 0;
            };
            Particle.prototype.update = function(deltaTime) {
              this.position.x += this.velocity.x * deltaTime;
              this.position.y += this.velocity.y * deltaTime;
              this.velocity.x += this.acceleration.x * deltaTime;
              this.velocity.y += this.acceleration.y * deltaTime;
              this.age += deltaTime;
            };
            Particle.prototype.draw = function(context, image) {
              function ease(t) {
                return (--t) * t * t + 1;
              }
              var size = image.width * ease(this.age / settings.particles.duration);
              context.globalAlpha = 1 - this.age / settings.particles.duration;
              context.drawImage(image, this.position.x - size / 2, this.position.y - size / 2, size, size);
            };
            return Particle;
          })();
          
          /*
           * ParticlePool class
           */
          var ParticlePool = (function() {
            var particles,
                firstActive = 0,
                firstFree   = 0,
                duration    = settings.particles.duration;
            
            function ParticlePool(length) {
              // create and populate particle pool
              particles = new Array(length);
              for (var i = 0; i < particles.length; i++)
                particles[i] = new Particle();
            }
            ParticlePool.prototype.add = function(x, y, dx, dy) {
              particles[firstFree].initialize(x, y, dx, dy);
              
              // handle circular queue
              firstFree++;
              if (firstFree   == particles.length) firstFree   = 0;
              if (firstActive == firstFree       ) firstActive++;
              if (firstActive == particles.length) firstActive = 0;
            };
            ParticlePool.prototype.update = function(deltaTime) {
              var i;
              
              // update active particles
              if (firstActive < firstFree) {
                for (i = firstActive; i < firstFree; i++)
                  particles[i].update(deltaTime);
              }
              if (firstFree < firstActive) {
                for (i = firstActive; i < particles.length; i++)
                  particles[i].update(deltaTime);
                for (i = 0; i < firstFree; i++)
                  particles[i].update(deltaTime);
              }
              
              // remove inactive particles
              while (particles[firstActive].age >= duration && firstActive != firstFree) {
                firstActive++;
                if (firstActive == particles.length) firstActive = 0;
              }
              
              
            };
            ParticlePool.prototype.draw = function(context, image) {
              // draw active particles
              if (firstActive < firstFree) {
                for (i = firstActive; i < firstFree; i++)
                  particles[i].draw(context, image);
              }
              if (firstFree < firstActive) {
                for (i = firstActive; i < particles.length; i++)
                  particles[i].draw(context, image);
                for (i = 0; i < firstFree; i++)
                  particles[i].draw(context, image);
              }
            };
            return ParticlePool;
          })();
          
          /*
           * Putting it all together
           */
          (function(canvas) {
            var context = canvas.getContext('2d'),
                particles = new ParticlePool(settings.particles.length),
                particleRate = settings.particles.length / settings.particles.duration, // particles/sec
                time;
            
            // get point on heart with -PI <= t <= PI
            function pointOnHeart(t) {
              return new Point(
                160 * Math.pow(Math.sin(t), 3),
                130 * Math.cos(t) - 50 * Math.cos(2 * t) - 20 * Math.cos(3 * t) - 10 * Math.cos(4 * t) + 25
              );
            }
            
            // creating the particle image using a dummy canvas
            var image = (function() {
              var canvas  = document.createElement('canvas'),
                  context = canvas.getContext('2d');
              canvas.width  = settings.particles.size;
              canvas.height = settings.particles.size;
              // helper function to create the path
              function to(t) {
                var point = pointOnHeart(t);
                point.x = settings.particles.size / 2 + point.x * settings.particles.size / 350;
                point.y = settings.particles.size / 2 - point.y * settings.particles.size / 350;
                return point;
              }
              // create the path
              context.beginPath();
              var t = -Math.PI;
              var point = to(t);
              context.moveTo(point.x, point.y);
              while (t < Math.PI) {
                t += 0.01; // baby steps!
                point = to(t);
                context.lineTo(point.x, point.y);
              }
              context.closePath();
              // create the fill
              context.fillStyle = '#ea80b0';
              context.fill();
              // create the image
              var image = new Image();
              image.src = canvas.toDataURL();
              return image;
            })();
            
            // render that thing!
            function render() {
              // next animation frame
              requestAnimationFrame(render);
              
              // update time
              var newTime   = new Date().getTime() / 1000,
                  deltaTime = newTime - (time || newTime);
              time = newTime;
              
              // clear canvas
              context.clearRect(0, 0, canvas.width, canvas.height);
              
              // create new particles
              var amount = particleRate * deltaTime;
              for (var i = 0; i < amount; i++) {
                var pos = pointOnHeart(Math.PI - 2 * Math.PI * Math.random());
                var dir = pos.clone().length(settings.particles.velocity);
                particles.add(canvas.width / 2 + pos.x, canvas.height / 2 - pos.y, dir.x, -dir.y);
              }
              
              // update and draw particles
              particles.update(deltaTime);
              particles.draw(context, image);
            }
            
            // handle (re-)sizing of the canvas
            function onResize() {
              canvas.width  = canvas.clientWidth;
              canvas.height = canvas.clientHeight;
            }
            window.onresize = onResize;
            
            // delay rendering bootstrap
            setTimeout(function() {
              onResize();
              render();
            }, 10);
          })(document.getElementById('pinkboard'));</script>
          
          </body>
          </html>
          

          第二款:html5通過canvas實現愛心氣球上升動畫特效

          寓意:將想說的話打開一顆顆的愛心氣球上,隨著氣球不斷的升空,讓整個氛圍可更加地纏綿,看到此處可以有感動的淚水。

          代碼難度系數★★★

          新建index.html,復制以下代碼保存在瀏覽器中打開即可。

          <!doctype html>
          <html>
          <head>
          <meta charset="utf-8">
          <title>情人節快樂:)</title>
          
          <style>
          canvas {
          	position: absolute;
          	top: 0;
          	left: 0;
          }</style>
          </head>
          <body>
          <canvas id=c></canvas>
          
          <script>
          var w = c.width = window.innerWidth,
          		h = c.height = window.innerHeight,
          		ctx = c.getContext( '2d' ),
          		
          		opts = {
          			phrases: [ "Don't die\nit's not hard", "You're the Best", "Every day,\nYou're beautiful", "Every occasion,\nYou're clever", "A world without You?\nNah", "Keep kicking ass", "You're better than them,\nwhoever they are", "You're just amazing", "You are,\ntherefore I am", "Nothing better than You \ncould have happened to the world" ],
          			balloons: 10,
          			baseVelY: -1,
          			addedVelY: -1,
          			baseVelX: -.25,
          			addedVelX: .5,
          			baseSize: 20,
          			addedSize: 10,
          			baseSizeAdder: 2,
          			addedSizeAdder: 2,
          			baseIncrementer: .01,
          			addedIncrementer: .03,
          			baseHue: -10,
          			addedHue: 30,
          			font: '15px Verdana'
          		},
          		
          		cycle = 0,
          		balloons = [];
          
          ctx.font = opts.font;
          
          function Balloon(){
          	this.reset();
          }
          Balloon.prototype.reset = function(){
          	
          	this.size = opts.baseSize + opts.addedSize * Math.random();
          	this.sizeAdder = opts.baseSizeAdder + opts.addedSizeAdder * Math.random();
          	this.incrementer = opts.baseIncrementer + opts.addedIncrementer * Math.random();
          	
          	this.tick = 0;
          	
          	this.x = Math.random() * w;
          	this.y = h + this.size;
          	
          	this.vx = opts.baseVelX + opts.addedVelX * Math.random();
          	this.vy = opts.baseVelY + opts.addedVelY * Math.random();
          	
          	this.color = 'hsla(hue,70%,60%,.8)'.replace( 'hue', opts.baseHue + opts.addedHue * Math.random() );
          	this.phrase = opts.phrases[ ++cycle % opts.phrases.length ].split( '\n' );
          	this.lengths = [];
          	
          	for( var i = 0; i < this.phrase.length; ++i )
          		this.lengths.push( -ctx.measureText( this.phrase[ i ] ).width / 2 );
          }
          Balloon.prototype.step = function(){
          	
          	this.tick += this.incrementer;
          	this.x += this.vx;
          	this.y += this.vy;
          	
          	var size = this.size + this.sizeAdder * Math.sin( this.tick );
          	
          	ctx.lineWidth = size / 40;
          	ctx.strokeStyle = '#eee';
          	ctx.beginPath();
          	ctx.moveTo( this.x, this.y - 2 );
          	ctx.lineTo( this.x, this.y + size );
          	ctx.stroke();
          	ctx.fillStyle = this.color;
          	
          	ctx.translate( this.x, this.y );
          	ctx.rotate( Math.PI / 4 );
          	//ctx.fillRect( -size / 2, -size / 2, size / 2, size / 2 );
          	ctx.beginPath();
          	ctx.moveTo( 0, 0 );
          	ctx.arc( -size / 2, -size / 2 + size / 4, size / 4, Math.PI / 2, Math.PI * 3 / 2 );
          	ctx.arc( -size / 2 + size / 4, -size / 2, size / 4, Math.PI, Math.PI * 2 );
          	ctx.lineTo( 0, 0 );
          	ctx.fill();
          	ctx.rotate( -Math.PI / 4 );
          	ctx.translate( -this.x, -this.y );
          	
          	ctx.translate( this.x, this.y + size + 15 );
          	ctx.scale( size / this.size, size / this.size );
          	ctx.fillStyle = '#eee';
          	for( var i = 0; i < this.phrase.length; ++i )
          		ctx.fillText( this.phrase[ i ], this.lengths[ i ], i * 15 );
          	ctx.scale( this.size / size, this.size / size );
          	ctx.translate( -this.x, -( this.y + size + 15 ) );
          	
          	if( this.y < -size * 3 )
          		this.reset();
          	
          }
          
          function anim(){
          	
          	window.requestAnimationFrame( anim );
          	
          	ctx.fillStyle = '#222';
          	ctx.fillRect( 0, 0, w, h );
          	
          	if( balloons.length < opts.balloons && Math.random() < .01 )
          		balloons.push( new Balloon );
          	
          	for( var i = 0; i < balloons.length; ++i )
          		balloons[ i ].step();
          }
          anim();</script>
          
          </body>
          </html>
          

          第三款:jQuery+css3實現愛心雨動畫特效

          寓意:天空中下起了愛心雨,襯托的房間變得溫暖,也讓整個場景都變得溫馨無比,想必此時可以有一個大大的擁抱。

          代碼難度系數★★★

          代碼有image、js和html,所以不好貼出來,有需要的朋友直接問我要吧。

          總結:程序員的工作本身就很枯燥,特定找了幾個好看的特效拿出來和大家分享,希望大家能夠快樂每一天,上述代碼親測可用,歡迎點贊收藏。

          《完》

          大家如果喜歡的話麻煩點贊、關注、轉發,謝謝大家。


          主站蜘蛛池模板: 台湾无码一区二区| 一区二区在线播放视频| 久久人妻无码一区二区| 视频在线一区二区| 无码日韩人妻av一区免费| 日本精品高清一区二区| 国产成人av一区二区三区不卡 | 精品国产一区二区三区麻豆| 夜色阁亚洲一区二区三区 | 亚洲老妈激情一区二区三区| 日韩aⅴ人妻无码一区二区| 久久无码人妻一区二区三区 | 一区二区精品在线观看| 国产精品视频一区| 亚洲高清一区二区三区电影| 色久综合网精品一区二区| 久久久综合亚洲色一区二区三区| 东京热无码av一区二区| 无码AV一区二区三区无码| 日本一区视频在线播放| 日韩精品一区二区午夜成人版| 国产精品亚洲一区二区三区久久| 国产日韩精品一区二区在线观看播放| 亚洲AV无码一区二区三区牛牛| 3d动漫精品啪啪一区二区中| 亚洲国产精品一区二区久久| 日本一区二区在线| 无码日韩精品一区二区免费暖暖 | 国产精品亚洲午夜一区二区三区| 无码国产精品一区二区免费式芒果 | 国产成人AV一区二区三区无码| 欧洲精品无码一区二区三区在线播放| 亚洲日本一区二区三区在线不卡 | 国产精品视频一区二区三区| 韩国一区二区视频| 国产肥熟女视频一区二区三区| 夜色阁亚洲一区二区三区| 成人区人妻精品一区二区不卡网站| 国产在线一区二区在线视频| 性色A码一区二区三区天美传媒 | 性色AV一区二区三区|