<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)畫【036】

          共 3250字,需瀏覽 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

          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 {
            width96px;
            height96px;
            border:10px solid;
            background:rgba(255255255, .2) ;
            border-color: white white transparent transparent;
            border-radius50%;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            animation: rotation 2s ease-in-out infinite;
          }
          span::after{
            content'';
            border24px solid;
            border-color: red red transparent transparent;
            border-radius50%;
          }

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

          Part3原理詳解

          步驟1

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

          • 寬度、高度均為96px
          • 背景色:rgba(255, 255, 255, .2)
          width: 96px;
            height: 96px;
            background: rgba(255255255.2); 

          效果圖如下

          步驟2

          設(shè)置span邊框

          • 邊框大?。?0px
          • 形狀:直線
          • 顏色:上/右邊框?yàn)榘咨?下/左邊框?yàn)橥该?/section>

          效果圖如下

          步驟3

          對(duì)span設(shè)置flex布局,使得其中的元素上下左右居中

           display: flex;
            align-items: center;
            justify-content: center;

          步驟4

          使用span::after偽類元素作為紅色部分

          設(shè)置

          • 邊框大小及形狀:24px solid
          • 上/右邊框顏色為紅色 下/左邊框顏色為透明
           border: 24px solid;
            border-color: red red transparent transparent;

          效果圖如下

          步驟5

          對(duì)span、span::after圓角化

          border-radius: 50%;

          效果圖如下

          步驟6

          為span添加動(dòng)畫

          • 順時(shí)針旋轉(zhuǎn)(0-360度) 2s 無限循環(huán)
          • 速度曲線:ease-in-out
          animation: rotation 2s ease-in-out infinite;
          @keyframes rotation {
            0% {
              transform: rotate(0deg)
            }
            100% {
              transform: rotate(360deg)
            }
          }

          效果圖如下

          Part4結(jié)語

          希望對(duì)您有所幫助

          如有錯(cuò)誤歡迎小伙伴指正~

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

          如果您覺得寫得可以的話

          請(qǐng)點(diǎn)個(gè)贊吧

          謝謝支持??


          瀏覽 26
          點(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>
                  天堂欧美城 | 免费视频色情 | 日批视频网址 | 日本一道码高清无码 | 美女嗦鸡吧视频网站 |