<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          炫酷水波浪Loading過(guò)渡動(dòng)畫

          共 9116字,需瀏覽 19分鐘

           ·

          2021-08-13 20:50

          效果展示

          Demo代碼

          HTML

          <!DOCTYPE html>
          <html lang="en">

              <head>
                  <meta charset="UTF-8">
                  <meta http-equiv="X-UA-Compatible" content="IE=edge">
                  <meta name="viewport" content="width=device-width, initial-scale=1.0">
                  <link rel="stylesheet" href="style.css">
                  <title>Document</title>
              </head>

              <body>
                  <section>
                      <div class="circle">
                          <div class="wave"></div>
                      </div>
                  </section>
              </body>

          </html>

          CSS

          /* 
          模版css樣式
          僅供演示使用 
          */


          htmlbody {
           margin0;
           height100%;


          body {
           display: flex;
           justify-content: center;
           align-items: center;
           background-color#12383e;
          }

          section {
           width650px;
           height300px;
           padding10px;
           position: relative;
           display: flex;
           align-items: center;
           justify-content: center;
           border-radius20px;
           border18px solid white;
           overflow: hidden;
          }

          section::before {
           content'CSS';
           width150px;
           height150px;
           text-align: center;
           line-height250px;
           background-color#00cec9;
           position: absolute;
           top: -76px;
           right: -76px;
           transformtranslate(50%, -50%);
           font-size32px;
           font-weight500;
           font-family: sans-serif;
           color: white;
           transformrotate(45deg);
          }

          section::after {
           content'';
           position: absolute;
           width100%;
           height100%;
           border10px solid white;
           border-radius20px;
          }

          /* 實(shí)現(xiàn)代碼 */

          .circle {
           position: relative;
           width200px;
           height200px;
           background#b0f4ff;
           border-radius50%;
           overflow: hidden;
           animation: loadingBreath 5s infinite linear;
          }

          .circle::before {
           content'Loading...';
           position: absolute;
           top50%;
           left50%;
           transformtranslate(-50%, -50%);
           font-size18px;
           letter-spacing2px;
           color#10a789;
           font-family: sans-serif;
           z-index2;
          }

          .circle::after {
           content'';
           position: absolute;
           width100%;
           height25%;
           bottom0;
           background-imagelinear-gradient(to top, #12c8e0, #36e9ff, #5ffbf1);
           animation: loadingRun 5s linear infinite;
          }

          .wave::before {
           content'';
           position: absolute;
           left: -50%;
           width200%;
           height200%;
           z-index1;
           background-color#85f7fb;
           border-radius52% 25% 62% 69%/25% 38%;
           animation: loadingWave 5s linear infinite;
          }

          .wave::after {
           content'';
           position: absolute;
           left: -50%;
           width200%;
           height200%;
           z-index1;
           background-color#d0f4ff;
           border-radius42% 38% 40% 62%/28% 35%;
           animation: loadingWave 5s ease-in-out infinite;
          }

          /* 呼吸燈動(dòng)畫 */

          @keyframes loadingBreath {
           0% {
            box-shadow0 0 5px 0 #85f7fb;
           }
           25% {
            box-shadow0 0 20px 0 #85f7fb;
           }
           50% {
            box-shadow0 0 5px 0 #85f7fb;
           }
           75% {
            box-shadow0 0 20px 0 #85f7fb;
           }
           100% {
            box-shadow0 0 5px 0 #85f7fb;
           }
          }

          /* 底部液體上升動(dòng)畫 */

          @keyframes loadingRun {
           0% {
            height25%;
           }
           100% {
            height100%;
           }
          }

          /* wave動(dòng)畫 */

          @keyframes loadingWave {
           0% {
            top: -100%;
            transformrotate(0);
           }
           100% {
            top: -200%;
            transformrotate(360deg);
           }
          }

          原理詳解

          步驟1

          從效果圖上分析

          可以將其分為兩個(gè)部分

          • 容器
          • 波浪

          這里使用兩個(gè)div,一個(gè)為circle類,一個(gè)為wave類,分別代表容器和wave

                      <div class="circle">
                          <div class="wave"></div>
                      </div>

          步驟2

          設(shè)置circle類

          • 相對(duì)定位
          • 寬度、高度均為200px
          • 背景色:#b0f4ff
          • 圓角:50%
          .circle {
           position: relative;
           width200px;
           height200px;
           background#b0f4ff;
           border-radius50%;
          }

          效果圖如下:

          步驟3

          利用.circle::befor偽元素

          用于顯示“Loading...”字樣

          設(shè)置為

          • 絕對(duì)定位
          • 使其位于「正中間」( top: 50%; left: 50%; transform: translate(-50%, -50%);)
          • 字體大小:18px
          • 顏色:#10a789;
          • z-index:2(比1大就行 使其文字處于最上層)
          .circle::before {
           content'Loading...';
           position: absolute;
           top50%;
           left50%;
           transformtranslate(-50%, -50%);
           font-size18px;
           letter-spacing2px;
           color#10a789;
           font-family: sans-serif;
           z-index2;
          }

          效果圖如下:

          步驟4

          利用.circle::after偽元素

          設(shè)置為

          • 絕對(duì)定位(bottom: 0; )
          • 寬度:100%
          • 高度:25%
          • 背景顏色為漸變色 linear-gradient(to top, #12c8e0, #36e9ff, #5ffbf1);
          .circle::after {
           content'';
           position: absolute;
           width100%;
           height25%;
           bottom0;
           background-imagelinear-gradient(to top, #12c8e0, #36e9ff, #5ffbf1);
          }

          效果圖如下:

          步驟5

          為.circle::after偽元素添加動(dòng)畫

          使其隨時(shí)間其高度逐漸增大

          只需要明確兩個(gè)關(guān)鍵幀

          • 初始位置:height: 25%
          • 結(jié)束位置:height: 100%
          .circle::after {
           animation: loadingRun 5s linear infinite;
          }


          @keyframes loadingRun {
           0% {
            height25%;
           }
           100% {
            height100%;
           }
          }

          效果圖如下:

          步驟6

          對(duì)circle設(shè)置隱藏溢出

          .circle {
           overflow: hidden;
          }

          效果圖如下:

          步驟7

          這里先注釋circle隱藏溢出 以及 circle::after動(dòng)畫 便于后面單獨(dú)分析

          .circle {
           /* overflow: hidden; */
          }
          .circle::after {
           /* animation: loadingRun 5s linear infinite; */
          }

          然后我們使用wave的兩個(gè)偽元素.wave::before、.wave::afte與cirle::after產(chǎn)生波浪的效果

          首先設(shè)置wave::before

          • 絕對(duì)定位(left: -50%;)
          • 寬度、高度均為200%
          • z-index:1
          • 背景色:#85f7fb
          • border-radius: 52% 25% 62% 69%/25% 38%; 「重點(diǎn)」
          .wave::before {
           content'';
           position: absolute;
           left: -50%;
           width200%;
           height200%;
           z-index1;
           background-color#85f7fb;
           border-radius52% 25% 62% 69%/25% 38%;/*重點(diǎn)*/
          }

          效果圖如下:

          注:.wave::before z-index為1 大于circile(0) 小于.circle::before(2)

          為.wave::before 添加動(dòng)畫

          效果描述

          ?

          自身不斷旋轉(zhuǎn)的同時(shí) 也不斷上升

          ?
          .wave::before {
           animation: loadingWave 5s linear infinite;
          }

          @keyframes loadingWave {
           0% {
            top: -100%;
            transformrotate(0);
           }
           100% {
            top: -200%;
            transformrotate(360deg);
           }
          }

          效果圖如下:

          同理,對(duì)wave::after進(jìn)行同樣的設(shè)置

          不同在于?四邊圓角率與before不同、顏色淺一點(diǎn)

          border-radius: 42% 38% 40% 62%/28% 35%;
          background-color#d0f4ff;

          其他都一樣

          當(dāng)wave::after、before運(yùn)用同樣的動(dòng)畫時(shí)

          效果圖如下:

          步驟8

          取消circle隱藏溢出 以及 circle::after動(dòng)畫

          .circle {
           overflow: hidden; 
          }
          .circle::after {
            animation: loadingRun 5s linear infinite; 
          }

          效果圖如下:

          步驟9

          最后為cirlce添加一個(gè)呼吸燈動(dòng)畫效果

          .circle {
           animation: loadingBreath 5s infinite linear;
          }

          ```css

          @keyframes loadingBreath {
           0% {
            box-shadow0 0 5px 0 #85f7fb;
           }
           25% {
            box-shadow0 0 20px 0 #85f7fb;
           }
           50% {
            box-shadow0 0 5px 0 #85f7fb;
           }
           75% {
            box-shadow0 0 20px 0 #85f7fb;
           }
           100% {
            box-shadow0 0 5px 0 #85f7fb;
           }
          }

          得到最終效果圖

          結(jié)語(yǔ)

          學(xué)習(xí)參考:

          ?

          https://www.bilibili.com/video/BV1Ai4y1t7od https://developer.mozilla.org/zh-CN/docs/Web/CSS/::before

          ?

          文章僅作為學(xué)習(xí)筆記,記錄從0到1的一個(gè)過(guò)程

          希望對(duì)您有所幫助,如有錯(cuò)誤歡迎小伙伴指正~

          我是 海轟?(?ˊ?ˋ)?

          如果您覺(jué)得寫得可以的話,請(qǐng)點(diǎn)個(gè)贊吧

          謝謝支持??

          瀏覽 57
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  精品卡一卡二 | 日本三级在线 | 中文无码字幕视频 | 无码一区二区三区四区精品 | 美女被操视频91 |