<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>

          「HTML+CSS」自定義加載動(dòng)畫【030】

          共 3239字,需瀏覽 7分鐘

           ·

          2021-05-05 13:26

          效果展示

          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><span></span></section>
          </body>
          </html>

          CSS

          html,body{
            margin0;
            height100%;
          }
          body{
            display: flex;
            justify-content: center;
            align-items: center;
            background#263238;
          }
          section {
              width650px;
              height300px;
              padding10px;
              position: relative;
              display: flex;
              align-items: center;
              justify-content: center;
              border2px solid red;
          }
          span {
            width 96px;
            height96px;
            position: relative;
          }
          span::before,
          span::after{
            position: absolute;
            content'';
            width96px;
            height96px;
            top0;
            left0;
            background: white;
            border-radius50%;
            animation: animloader 2s linear infinite;
          }
          span::after{
            animation-delay1s;
          }
          @keyframes animloader {
            0% { transformscale(0); opacity1;}
            100% { transformscale(1); opacity0;}
          }

          原理詳解

          步驟1

          使用span標(biāo)簽,設(shè)置

          • 寬度、高度均為96px
            width: 96px;
            height: 96px;

          步驟2

          使用span::before、span::after偽類元素充當(dāng)白色波紋

          設(shè)置

          • 絕對(duì)定位(top:0 left:0)
          • 寬度、高度均為96px(這樣就是與原span重疊了)
          • 顏色:白色
           position: absolute;
            content: '';
            width: 96px;
            height: 96px;
            top: 0;
            left: 0;
            background: white;

          效果圖如下

          步驟3

          span::before、span::after圓角化

          border-radius: 50%;

          效果圖如下

          注:這里span、span::before、span::after三者都重疊在同一個(gè)位置了,其中span無顏色,其余為白色

          步驟4

          為span::before、span::after添加動(dòng)畫

          • 初始狀態(tài):大小為0(相對(duì)于原大小),顏色為(白,透明級(jí)別1)
          • 終止?fàn)顟B(tài):大小為1(相對(duì)于原大?。?,顏色為(白,透明級(jí)別0)
          animation: animloader 2s linear infinite;
          /*動(dòng)畫實(shí)現(xiàn)*/
          @keyframes animloader {
            0% {
              transform: scale(0);
              opacity: 1;
            }
            100% {
              transform: scale(1);
              opacity: 0;
            }
          }

          效果圖如下

          步驟5

          為了使span::before、span::after二者之間的動(dòng)畫產(chǎn)生視覺差效果

          對(duì)span::after進(jìn)行延時(shí)

          這樣同一時(shí)刻就可以看到兩個(gè)圓的變換了

          animation-delay: 1s;

          效果圖如下

          結(jié)語

          學(xué)習(xí)來源:

          ?

          https://codepen.io/bhadupranjal/pen/vYLZYqQ

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

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

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

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

          謝謝支持??


          瀏覽 38
          點(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>
                  色综合天| 黄色AV网探花 | 国产靠逼视频网站 | 天堂视频在线 | 在线播放【国产精品】 |