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

          共 3261字,需瀏覽 7分鐘

           ·

          2021-05-09 11:19

          Part1效果展示

          Part2Demo代碼

          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

          htmlbody {
            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 {
            width96px;
            height96px;
            position: relative;
            animation: rotation 2s linear infinite;
          }

          span::beforespan::after {
            position: absolute;
            content'';
            width24px;
            height24px;
            border-radius50%;
          }

          span::before {
            top0;
            left0;
            background-color: white;
          }

          span::after {
            bottom0;
            right0;
            background-color: red;
          }

          @keyframes rotation {
            0% {
              transformrotate(0deg)
            }
            100% {
              transformrotate(360deg)
            }
          }

          Part3原理詳解

          步驟1

          使用span標簽,設置

          • 寬度、高度均為96px
          • 相對定位
          • 背景色:yellow(這里只用作提示,后面會取消背景色的)
          width: 96px;
            height: 96px;
            position: relative;
            background-color: yellow;

          效果圖如下

          步驟2

          使用span::before、span::after偽類元素,設置

          • 寬度、高度均為24px
          • 絕對定位

          span::before

          • 顏色:白色
          • 位置:左上角

          span::after

          • 顏色:紅色
          • 位置:右下角
          span::before, span::after {
            position: absolute;
            content: ''; 
            width: 24px;
            height: 24px;
          }

          span::before {
            top: 0;
            left: 0;
            background-color: white;
          }

          span::after {
            bottom: 0;
            right: 0;
            background-color: red;
          }

          效果圖如下

          步驟3

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

          border-radius: 50%;

          效果圖如下

          步驟4

          取消span的背景色

          效果圖如下

          步驟5

          為span添加動畫

          • 順時針旋轉(0-360度) 2s 無限循環(huán)
          animation: rotation 2s linear infinite;

          @keyframes rotation {
            0% {
              transform: rotate(0deg)
            }
            100% {
              transform: rotate(360deg)
            }
          }

          效果圖如下

          Part4結語

          希望對您有所幫助

          如有錯誤歡迎小伙伴指正~

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

          如果您覺得寫得可以的話

          請點個贊吧

          謝謝支持??


          瀏覽 10
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

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

          手機掃一掃分享

          分享
          舉報
          <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>
                  色婷婷色婷婷色婷婷视频 | 久久久久久久久久久久久性性 | 国产精品99久久久精品无码 | 操屄视频免费 | 日本黄色视频在线免费观看 |