<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」自定義加載動畫【009】

          共 3682字,需瀏覽 8分鐘

           ·

          2021-04-25 13:15

          Part1前言

          昵稱:海轟

          標簽:程序猿一只|C++選手|學(xué)生

          Part2效果展示

          Part3Demo代碼

          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;
            border10px solid transparent;
            border-radius50%
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            border-bottom-color#FF3D00
            border-top-color#FF3D00;
            animation: rotation 1s linear infinite;
          }
          span::after{
            position: relative;
            content'';
            display: inline-block;
            width:  72px;
            height:  72px;
            border-radius50%;
            border10px solid transparent; 
            border10px solid #fff
          }
          @keyframes rotation {
            0% { transformrotate(0deg) }
            100% { transformrotate(360deg)
            }
          }

          Part4原理解釋

          動畫的核心部分就是span和span::after

          section僅作為提示框。

          步驟1

          將span元素設(shè)置為

          • 一個96??96px的正方形
          • 邊框為10px,白色,solid
              width : 96px;
              height: 96px;
              border: 10px solid #fff;

          效果圖如下

          步驟2

          span::after偽元素設(shè)置為:

          • 位于span正中
          • 邊長72??72px的正方形

          注:紅色部分即為span::after,為便于觀察才設(shè)置為紅色

          步驟3

          span::after設(shè)置

          • 邊框:10px 白色 solid
              border: 10px solid white;

          注:

          • 此時的span::after變成了變成(72+10+10)px 的正方形

          步驟4

          span

          • 下邊框設(shè)置為紅色
          • 上邊框設(shè)置為紅色
          border-bottom-color#FF3D00
          border-top-color#FF3D00;

          效果圖如下

          步驟5

          span和span::after

          • 圓角設(shè)置:50%
          border-radius: 50%;

          效果圖如下

          步驟6

          span

          • 四邊框顏色為透明
          border: 10px solid transparent;

          效果圖如下

          步驟7

          為span添加動畫

          animationrotation 1s linear infinite;
          /*動畫實現(xiàn)*/
            @keyframes rotation {
              0% { transformrotate(0deg) }
              100% { transformrotate(360deg)
              }

          效果圖如下

          Part5結(jié)語

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

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

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

          希望對您有所幫助,如有錯誤歡迎小伙伴指正~

          Part6系列文章

          「HTML+CSS」--自定義加載動畫【008】
          「HTML+CSS」--自定義加載動畫【007】
          「HTML+CSS」--自定義加載動畫【006】
          「HTML+CSS」--自定義加載動畫【005】
          「HTML+CSS」--自定義按鈕樣式【004】

          我是海轟?(?ˊ?ˋ)?,如果您覺得寫得可以的話,請點個贊吧

          謝謝支持??

          寫留言|查看留言

          瀏覽 24
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <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>
                  国产久视频 | 成人视频| 色哟哟一区二区三区四区 | 在线观看视频草女人啊啊 | 欧美一级日韩 |