<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)畫(huà)【006】

          共 4034字,需瀏覽 9分鐘

           ·

          2021-04-12 04:48

          Part1簡(jiǎn)介

          昵稱(chēng):海轟

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

          簡(jiǎn)介:因C語(yǔ)言結(jié)識(shí)編程,隨后轉(zhuǎn)入計(jì)算機(jī)專(zhuān)業(yè),有幸拿過(guò)國(guó)獎(jiǎng)、省獎(jiǎng)等,已保研。目前正在學(xué)習(xí)C++/Linux(真的真的太難了~)

          學(xué)習(xí)經(jīng)驗(yàn):扎實(shí)基礎(chǔ) + 多做筆記 + 多敲代碼 + 多思考 + 學(xué)好英語(yǔ)!

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

          Part4原理詳解

          動(dòng)畫(huà)的核心部分就是span和span::after,section僅作為提示框。

          步驟1

          將span元素設(shè)置為

          • 一個(gè)96??96px的正方形
          • 邊框?yàn)?0px,白色,solid
              width : 96px;
              height: 96px;
              border: 10px solid #fff;

          效果圖如下

          步驟2

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

          • 位于span正中
          • 邊長(zhǎng)72??72px的正方形

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

          步驟3

          span::after設(shè)置

          • 下邊框:10px 紅色 solid
              border: 10px solid transparent;
              border-bottom-color#FF3D00;

          效果圖如下

          步驟4

          span和span::after

          • border-radius均設(shè)置為50%
          border-radius: 50%;

          效果圖如下

          步驟5

          為span添加動(dòng)畫(huà)

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

          效果圖如下

          Part5結(jié)語(yǔ)

          學(xué)習(xí)來(lái)源:

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

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

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

          Part6系列文章

          「HTML+CSS」--自定義加載動(dòng)畫(huà)【005】
          「HTML+CSS」--自定義按鈕樣式【004】
          「HTML+CSS」--自定義按鈕樣式【003】
          「HTML+CSS」--自定義按鈕樣式【002】
          「HTML+CSS」--自定義按鈕樣式【001】

          我是海轟?(?ˊ?ˋ)?,如果您覺(jué)得寫(xiě)得可以的話,請(qǐng)點(diǎn)個(gè)贊吧

          謝謝支持??

          寫(xiě)留言|查看留言

          瀏覽 48
          點(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精品国产成人www | 爱草逼爱草逼爱草逼爱草逼爱草逼爱草逼 | 五月天Av成人在线播放 | 老欧性老太HD性 |