婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 實例講解使用SVG制作loading加載動畫的方法

實例講解使用SVG制作loading加載動畫的方法

熱門標簽:外呼線穩(wěn)定線路 呼和浩特外呼電銷系統(tǒng)排名 邢臺縣地圖標注app 阜陽企業(yè)外呼系統(tǒng) 地圖標注位置能賺錢嗎 外呼系統(tǒng)電話怎么投訴 南通數(shù)據(jù)外呼系統(tǒng)推廣 申請400電話流程簡介 pageadm實現(xiàn)地圖標注

今天和大家分享一個以SVG圖像為主的loading加載動畫,現(xiàn)在移動端網(wǎng)頁使用比較多,若還用GIF做loading圖片的話,可能會影響圖像的質(zhì)量,所以使用SVG是一個不錯的方式。

這次展示的代碼由 Aurer 編寫,前端人員只需要直接復制想要的SVG代碼就能直接使用,而且可以改變顏色。當然,對于好學的同學,也可以研究下這個代碼的編寫原理。

使用教程

接下來設計達人網(wǎng)小編為大家講解這個使用方法,其實是相當簡單的。

STEP 1: 復制你想要的SVG加載動畫代碼到<body>里面,小編隨意復制一個代碼如下:

XML/HTML Code復制內(nèi)容到剪貼板
  1. <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="30px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve">  
  2. <rect x="0" y="0" width="4" height="10" fill="#333" transform="translate(0 15.1665)">  
  3. <animateTransform attributeType="xml" attributeName="transform" type="translate" values="0 0; 0 20; 0 0" begin="0" dur="0.6s" repeatCount="indefinite"></animateTransform>  
  4. </rect>  
  5. <rect x="10" y="0" width="4" height="10" fill="#333" transform="translate(0 11.5002)">  
  6. <animateTransform attributeType="xml" attributeName="transform" type="translate" values="0 0; 0 20; 0 0" begin="0.2s" dur="0.6s" repeatCount="indefinite"></animateTransform>  
  7. </rect>  
  8. <rect x="20" y="0" width="4" height="10" fill="#333" transform="translate(0 1.83315)">  
  9. <animateTransform attributeType="xml" attributeName="transform" type="translate" values="0 0; 0 20; 0 0" begin="0.4s" dur="0.6s" repeatCount="indefinite"></animateTransform>  
  10. </rect>  
  11. </svg>  

此時代碼已經(jīng)可以帶動畫了,但沒顏色,請繼續(xù)看STEP2添加顏色。

STEP 2 : 為SVG圖像添加顏色

給你的樣式表添加如下樣式,里面的顏色代碼換上你喜歡的即!

XML/HTML Code復制內(nèi)容到剪貼板
  1. <style>  
  2. svg path,svg rect{fill: #FF6700;}   
  3. </style>  

完成!最終DEMO:

ionic庫中的加載動畫使用
ionic是一個用來開發(fā)混合手機應用的,開源的,免費的代碼庫。可以優(yōu)化html、css和js的性能,構(gòu)建高效的應用程序,而且還可以用于構(gòu)建Sass和AngularJS的優(yōu)化。ionic會是一個可以信賴的框架。
安裝很簡單,如果有npm,Window 和 Linux 上打開命令行工具執(zhí)行以下命令:

復制代碼
代碼如下:
$ npm install -g cordova ionic

Mac 系統(tǒng)上使用以下命令:

復制代碼
代碼如下:
sudo npm install -g cordova ionic

提示: IOS需要在Mac Os X. 和Xcode環(huán)境下面安裝使用。
如果你已經(jīng)安裝了以上環(huán)境,可以執(zhí)行以下命令來更新版本:

復制代碼
代碼如下:
npm update -g cordova ionic



復制代碼
代碼如下:
sudo npm update -g cordova ionic

下面我們來看一下具體的兩個加載相關(guān)的用法:

ionic 加載動作 $ionicLoading
$ionicLoading 是 ionic 默認的一個加載交互效果。里面的內(nèi)容也是可以在模板里面修改。
使用實例:
HTML 代碼:

XML/HTML Code復制內(nèi)容到剪貼板
  1. <html ng-app="ionicApp">  
  2.   <head>  
  3.     <meta charset="utf-8">  
  4.     <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">    
  5.        
  6.     <title>Ionic Modal</title>  
  7.   
  8.      <link href="http://www.runoob.com/static/ionic/css/ionic.min.css" rel="stylesheet">  
  9.     <script src="http://www.runoob.com/static/ionic/js/ionic.bundle.min.js"></script>  
  10.   </head>  
  11. <body ng-controller="AppCtrl">  
  12.        
  13.       <ion-view title="Home">  
  14.         <ion-header-bar>  
  15.           <h1 class="title">The Stooges</h1>  
  16.         </ion-header-bar>  
  17.         <ion-content has-header="true">  
  18.           <ion-list>  
  19.             <ion-item ng-repeat="stooge in stooges" href="#">{{stooge.name}}</ion-item>  
  20.           </ion-list>  
  21.         </ion-content>  
  22.       </ion-view>  
  23.        
  24.   </body>  
  25. </html>  

JavaScript 代碼

JavaScript Code復制內(nèi)容到剪貼板
  1. angular.module(‘ionicApp‘, [‘ionic‘])   
  2. .controller(‘AppCtrl‘, function($scope, $timeout, $ionicLoading) {   
  3.   
  4.   // Setup the loader   
  5.   $ionicLoading.show({   
  6.     content: ‘Loading‘,   
  7.     animation: ‘fade-in‘,   
  8.     showBackdrop: true,   
  9.     maxWidth: 200,   
  10.     showDelay: 0   
  11.   });   
  12.      
  13.   // Set a timeout to clear loader, however you would actually call the $ionicLoading.hide(); method whenever everything is ready or loaded.   
  14.   $timeout(function () {   
  15.     $ionicLoading.hide();   
  16.     $scope.stooges = [{name: ‘Moe‘}, {name: ‘Larry‘}, {name: ‘Curly‘}];   
  17.   }, 2000);   
  18.      
  19. });  

$ionicLoadingConfig
使用實例:

HTML 代碼

XML/HTML Code復制內(nèi)容到剪貼板
  1. <ion-content scroll="false" class="has-header">  
  2.   <p>  
  3.     <ion-spinner icon="android"></ion-spinner>  
  4.     <ion-spinner icon="ios"></ion-spinner>  
  5.     <ion-spinner icon="ios-small"></ion-spinner>  
  6.     <ion-spinner icon="bubbles" class="spinner-balanced"></ion-spinner>  
  7.     <ion-spinner icon="circles" class="spinner-energized"></ion-spinner>  
  8.   </p>  
  9.   
  10.   <p>  
  11.     <ion-spinner icon="crescent" class="spinner-royal"></ion-spinner>  
  12.   
  13.     <ion-spinner icon="dots" class="spinner-dark"></ion-spinner>  
  14.     <ion-spinner icon="lines" class="spinner-calm"></ion-spinner>  
  15.     <ion-spinner icon="ripple" class="spinner-assertive"></ion-spinner>  
  16.     <ion-spinner icon="spiral"></ion-spinner>  
  17.   </p>  
  18.   
  19.   
  20. </ion-content>  

 
CSS 代碼

CSS Code復制內(nèi)容到剪貼板
  1. body {   
  2.   cursorurl(‘http://www.runob.com/try/demo_source/finger.png‘), auto;   
  3. }       
  4. p {   
  5.   text-aligncenter;   
  6.   margin-bottom40px !important;   
  7. }   
  8. .spinner svg {   
  9.   width: 19% !important;   
  10.   height85px !important;   
  11. }  

JavaScript 代碼

JavaScript Code復制內(nèi)容到剪貼板
  1. angular.module(‘ionicApp‘, [‘ionic‘])   
  2.   
  3. .controller(‘MyCtrl‘, function($scope) {    
  4.      
  5. });  

標簽:德州 內(nèi)蒙古 辛集 鶴崗 撫順 蚌埠 黃山 楊凌

巨人網(wǎng)絡通訊聲明:本文標題《實例講解使用SVG制作loading加載動畫的方法》,本文關(guān)鍵詞  實例,講解,使用,SVG,制作,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《實例講解使用SVG制作loading加載動畫的方法》相關(guān)的同類信息!
  • 本頁收集關(guān)于實例講解使用SVG制作loading加載動畫的方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 天全县| 岳普湖县| 临朐县| 社会| 衡阳县| 沛县| 宜兰市| 府谷县| 吕梁市| 叙永县| 普兰县| 巍山| 双鸭山市| 集贤县| 青冈县| 杂多县| 花垣县| 武邑县| 景宁| 洞头县| 乌兰浩特市| 富平县| 奉节县| 奉新县| 武定县| 久治县| 永修县| 堆龙德庆县| 江华| 任丘市| 阿勒泰市| 开平市| 周宁县| 贵定县| 肇东市| 龙州县| 巴中市| 奉新县| 宽城| 泸州市| 凭祥市|