1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        「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)
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            国产系列在线观看 | 操大屁股美女 | 天天干天天操天天射 | 水蜜桃视频免费观看 | 亚洲无中文无码线在线观看 | 国产精品女人久久久久 | 免费成人在线观看视频 | 爱豆传煤无吗播放在线 | 欧美日韩三级在线 | 亚洲va欧美va国产综合定档 |