国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery實(shí)現(xiàn)炫麗的3d旋轉(zhuǎn)星空效果

2019-11-19 13:33:34
字體:
供稿:網(wǎng)友

本文實(shí)例講述了jQuery實(shí)現(xiàn)炫麗的3d旋轉(zhuǎn)星空效果。分享給大家供大家參考,具體如下:

該特效也是在Jquery插件庫中找到的,感覺效果不錯(cuò),說不定以后項(xiàng)目中要有絢麗的星空背景,拿來即用,收藏了下。

下載解壓后的目錄結(jié)構(gòu)

index.html頁面代碼:

<!doctype html><html lang="zh"><head>  <meta charset="UTF-8">  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">   <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>jQuery和CSS3超絢麗的3D星空動畫特效</title>  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>  <style class="cp-pen-styles">body {   background: radial-gradient(200% 100% at bottom center, #0070aa, #0b2570, #000035, #000);   background: radial-gradient(220% 105% at top center, #000 10%, #000035 40%, #0b2570 65%, #0070aa);   background-attachment: fixed;   overflow: hidden;  }  @keyframes rotate {   0% {    transform: perspective(400px) rotateZ(20deg) rotateX(-40deg) rotateY(0);   }   100% {    transform: perspective(400px) rotateZ(20deg) rotateX(-40deg) rotateY(-360deg);   }  }  .stars {   transform: perspective(500px);   transform-style: preserve-3d;   position: absolute;   bottom: 0;   perspective-origin: 50% 100%;   left: 50%;   animation: rotate 90s infinite linear;  }  .star {   width: 2px;   height: 2px;   background: #F7F7B6;   position: absolute;   top: 0;   left: 0;   transform-origin: 0 0 -300px;   transform: translate3d(0, 0, -300px);   backface-visibility: hidden;  }  </style></head><body>  <div class="stars">  </div>  <script src='js/stopExecutionOnTimeout.js'></script>  <script>  $(document).ready(function () {    var stars = 800;    var $stars = $('.stars');    var r = 800;    for (var i = 0; i < stars; i++) {      if (window.CP.shouldStopExecution(1)) {        break;      }      var $star = $('<div/>').addClass('star');      $stars.append($star);    }    window.CP.exitedLoop(1);    $('.star').each(function () {      var cur = $(this);      var s = 0.2 + Math.random() * 1;      var curR = r + Math.random() * 300;      cur.css({        transformOrigin: '0 0 ' + curR + 'px',        transform: ' translate3d(0,0,-' + curR + 'px) rotateY(' + Math.random() * 360 + 'deg) rotateX(' + Math.random() * -50 + 'deg) scale(' + s + ',' + s + ')'      });    });  });  </script></body></html>

運(yùn)行的效果如下:

其中stopExecutionOnTimeout.js如下:

復(fù)制代碼 代碼如下:
"use strict";"object"!=typeof window.CP&&(window.CP={}),window.CP.PenTimer={programNoLongerBeingMonitored:!1,timeOfFirstCallToShouldStopLoop:0,_loopExits:{},_loopTimers:{},START_MONITORING_AFTER:2e3,STOP_ALL_MONITORING_TIMEOUT:5e3,MAX_TIME_IN_LOOP_WO_EXIT:2200,exitedLoop:function(o){this._loopExits[o]=!0},shouldStopLoop:function(o){if(this.programKilledSoStopMonitoring)return!0;if(this.programNoLongerBeingMonitored)return!1;if(this._loopExits[o])return!1;var t=this._getTime();if(0===this.timeOfFirstCallToShouldStopLoop)return this.timeOfFirstCallToShouldStopLoop=t,!1;var i=t-this.timeOfFirstCallToShouldStopLoop;if(i<this.START_MONITORING_AFTER)return!1;if(i>this.STOP_ALL_MONITORING_TIMEOUT)return this.programNoLongerBeingMonitored=!0,!1;try{this._checkOnInfiniteLoop(o,t)}catch(n){return this._sendErrorMessageToEditor(),this.programKilledSoStopMonitoring=!0,!0}return!1},_sendErrorMessageToEditor:function(){try{if(this._shouldPostMessage()){var o={action:"infinite-loop",line:this._findAroundLineNumber()};parent.postMessage(JSON.stringify(o),"*")}else this._throwAnErrorToStopPen()}catch(t){this._throwAnErrorToStopPen()}},_shouldPostMessage:function(){return document.location.href.match(/boomerang/)},_throwAnErrorToStopPen:function(){throw"We found an infinite loop in your Pen. We've stopped the Pen from running. Please correct it or contact support@codepen.io."},_findAroundLineNumber:function(){var o=new Error,t=0;if(o.stack){var i=o.stack.match(/boomerang/S+:(/d+):/d+/);i&&(t=i[1])}return t},_checkOnInfiniteLoop:function(o,t){if(!this._loopTimers[o])return this._loopTimers[o]=t,!1;var i=t-this._loopTimers[o];if(i>this.MAX_TIME_IN_LOOP_WO_EXIT)throw"Infinite Loop found on loop: "+o},_getTime:function(){return+new Date}},window.CP.shouldStopExecution=function(o){return window.CP.PenTimer.shouldStopLoop(o)},window.CP.exitedLoop=function(o){window.CP.PenTimer.exitedLoop(o)};

效果還是挺不錯(cuò)的,你可以改變背景顏色等等定制。

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery切換特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對大家jQuery程序設(shè)計(jì)有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 开鲁县| 邵东县| 临海市| 淮南市| 吉隆县| 苍南县| 子长县| 梁平县| 昆明市| 彭山县| 府谷县| 宜川县| 伊宁市| 鹿泉市| 朝阳区| 湟源县| 梅州市| 西林县| 濉溪县| 普兰店市| 运城市| 卢氏县| 和田县| 汪清县| 宾阳县| 玉树县| 邢台县| 肥西县| 武义县| 庆云县| 永川市| 房山区| 荔波县| 上蔡县| 阿克陶县| 蒙自县| 乐亭县| 石狮市| 西峡县| 上高县| 元氏县|