• <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
  • <th id="l3qpx"><progress id="l3qpx"></progress></th>
      <th id="l3qpx"></th>
      <dd id="l3qpx"><font id="l3qpx"></font></dd>
      <th id="l3qpx"></th>
      0712-2888027 189-8648-0214
      微信公眾號(hào)

      孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號(hào)

      當(dāng)前位置:主頁(yè) > 技術(shù)支持 > HTML5/CSS3 > 純CSS3實(shí)現(xiàn)動(dòng)畫(huà)圓弧進(jìn)度條

      純CSS3實(shí)現(xiàn)動(dòng)畫(huà)圓弧進(jìn)度條

      時(shí)間:2016-02-19來(lái)源:風(fēng)信官網(wǎng) 點(diǎn)擊: 1687次

      來(lái)自國(guó)外的一個(gè)牛人寫(xiě)的代碼,根據(jù)css3的clip、transformanimation來(lái)實(shí)現(xiàn)的效果,所以你需要很清楚的知道這些屬性是具有哪些作用的才能明白他這個(gè)CSS的原理。
      純CSS3實(shí)現(xiàn)動(dòng)畫(huà)圓弧進(jìn)度條

      代碼如下:

      <div class="wrapper" data-anim="base wrapper">
        <div class="circle" data-anim="base left"></div>
        <div class="circle" data-anim="base right"></div>
      </div>

      首先定義基本樣式:

      
      .wrapper {
        width: 100px; /* Set the size of the progress bar */
        height: 100px;
        position: absolute; /* Enable clipping */
        clip: rect(0px, 100px, 100px, 50px); /* Hide half of the progress bar */
      }
      /* Set the sizes of the elements that make up the progress bar */
      .circle {
        width: 80px;
        height: 80px;
        border: 10px solid green;
        border-radius: 50px;
        position: absolute;
        clip: rect(0px, 50px, 100px, 0px);
      }

      接著是動(dòng)畫(huà)規(guī)則

      /* Using the data attributes for the animation selectors. */
      /* Base settings for all animated elements */
      div[data-anim~=base] {
        -webkit-animation-iteration-count: 1;  /* Only run once */
        -webkit-animation-fill-mode: forwards; /* Hold the last keyframe */
        -webkit-animation-timing-function:linear; /* Linear animation */
      }
      
      .wrapper[data-anim~=wrapper] {
        -webkit-animation-duration: 0.01s; /* Complete keyframes asap */
        -webkit-animation-delay: 3s; /* Wait half of the animation */
        -webkit-animation-name: close-wrapper; /* Keyframes name */
      }
      
      .circle[data-anim~=left] {
        -webkit-animation-duration: 6s; /* Full animation time */
        -webkit-animation-name: left-spin;
      }
      
      .circle[data-anim~=right] {
        -webkit-animation-duration: 3s; /* Half animation time */
        -webkit-animation-name: right-spin;
      }

      最后是動(dòng)畫(huà)幀

      /* Rotate the right side of the progress bar from 0 to 180 degrees */
      @-webkit-keyframes right-spin {
        from {
          -webkit-transform: rotate(0deg);
        }
        to {
          -webkit-transform: rotate(180deg);
        }
      }
      /* Rotate the left side of the progress bar from 0 to 360 degrees */
      @-webkit-keyframes left-spin {
        from {
          -webkit-transform: rotate(0deg);
        }
        to {
          -webkit-transform: rotate(360deg);
        }
      }
      /* Set the wrapper clip to auto, effectively removing the clip */
      @-webkit-keyframes close-wrapper {
        to {
          clip: rect(auto, auto, auto, auto);
        }
      }

      操作原理:

      首先:是定義三個(gè)動(dòng)畫(huà),第一個(gè)是最外層,讓他只顯示一半,然后運(yùn)行3s,同時(shí)右邊運(yùn)行3s,從0到180度。

      接著:到了180度之后,釋放外層的顯示一半,讓他自動(dòng)顯示其他。然后右邊的停止動(dòng)畫(huà)并停在那里。

      最后:左邊的在原來(lái)的基礎(chǔ)(跟右邊一樣運(yùn)行3s,同樣轉(zhuǎn)過(guò)180度)再繼續(xù)轉(zhuǎn)動(dòng)180度。

      演示地址:pure css circular progress bar

      熱門(mén)關(guān)鍵詞: CSS3 動(dòng)畫(huà)圓弧 進(jìn)度條
      欄目列表
      推薦內(nèi)容
      熱點(diǎn)內(nèi)容
      展開(kāi)
      欧美一区二区三区免费A级视频,亚洲精品中文字幕综合,动漫精品中文字幕无码第一页,1024亚洲国产综合 亚太影院 柯西贝尔-游戏赚网
    1. <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
    2. <th id="l3qpx"><progress id="l3qpx"></progress></th>
        <th id="l3qpx"></th>
        <dd id="l3qpx"><font id="l3qpx"></font></dd>
        <th id="l3qpx"></th>