欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CSS實(shí)現(xiàn)多層嵌套結(jié)構(gòu)最外層旋轉(zhuǎn)其它層不旋轉(zhuǎn)效果

  發(fā)布時(shí)間:2020-02-05 16:45:09   作者:神奇的程序員   我要評(píng)論
這篇文章主要介紹了CSS實(shí)現(xiàn)多層嵌套結(jié)構(gòu)最外層旋轉(zhuǎn)其它層不旋轉(zhuǎn)效果,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

有這樣一個(gè)場(chǎng)景:一個(gè)圓形容器,最外層容器的背景為圓弧,現(xiàn)在要將最外層的圓弧進(jìn)行旋轉(zhuǎn),保證里面的容器里面的內(nèi)容不進(jìn)行旋轉(zhuǎn),接下來將跟大家分享一種解決方案,先看下最終實(shí)現(xiàn)的效果:

 

實(shí)現(xiàn)思路

  • 最外層div設(shè)置邊框倒角百分之50,溢出隱藏
  • 設(shè)置最外層背景為圓弧的背景圖
  • 定義外層旋轉(zhuǎn)動(dòng)畫,旋轉(zhuǎn)度數(shù)為正數(shù)
  • 定義內(nèi)層旋轉(zhuǎn)動(dòng)畫,旋轉(zhuǎn)度數(shù)為負(fù)數(shù)
  • 啟動(dòng)動(dòng)畫,開始旋轉(zhuǎn)
  • 外層為正數(shù)旋轉(zhuǎn),內(nèi)層為負(fù)數(shù)旋轉(zhuǎn),剛好抵消,理想效果實(shí)現(xiàn)

實(shí)現(xiàn)過程

dom結(jié)構(gòu)部分:布局外層div和內(nèi)層div

load-panel為外層div, headPortrait-img-panel 為內(nèi)層div, loadWhirl 為外層旋轉(zhuǎn)動(dòng)畫, avatarRotation 為內(nèi)層旋轉(zhuǎn)動(dòng)畫。

<!--頭像區(qū)域-->
<div class="headPortrait-panel">
    <!--加載層-->
    <div class="load-panel loadWhirl">
        <!--頭像顯示層-->
        <div class="headPortrait-img-panel avatarRotation">
            <img src="../assets/img/login/LoginWindow_BigDefaultHeadImage@2x.png"/>
        </div>
    </div>
</div>

css部分:對(duì)樣式進(jìn)行布局,實(shí)現(xiàn)旋轉(zhuǎn)動(dòng)畫邏輯。

  /*頭像區(qū)域*/
  .headPortrait-panel{
    width: 100%;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 50px;

    /*加載層*/
    .load-panel{
      width: 240px;
      height: 240px;
      border-radius: 50%;
      display: flex;
      justify-content: center;
      align-items: center;
      background: url("../img/login/loading-circle@2x.png");

      img{
        width: 100%;
        height: 100%;
      }

      // 頭像旋轉(zhuǎn)動(dòng)畫
      .avatarRotation{
        animation: internalAvatar 3s linear;
        // 動(dòng)畫無限循環(huán)
        animation-iteration-count:infinite;
      }

      /*頭像顯示層*/
      .headPortrait-img-panel{
        width: 200px;
        height: 200px;
        border-radius: 50%;
        overflow: hidden;
        border: solid 1px #ebeced;

        img{
          width: 100%;
          height: 100%;
        }
      }
    }

    // 外部旋轉(zhuǎn)動(dòng)畫
    .loadWhirl{
      animation: externalHalo 3s linear;
      // 動(dòng)畫無限循環(huán)
      animation-iteration-count:infinite;
    }
  }

  // 定義外部光環(huán)旋轉(zhuǎn)動(dòng)畫
  @keyframes externalHalo {
    0%{
      transform: rotate(0deg);
    }
    25%{
      transform: rotate(90deg);
    }
    50%{
      transform: rotate(180deg);
    }
    100%{
      transform: rotate(360deg);
    }
  }

  // 定義內(nèi)部頭像旋轉(zhuǎn)動(dòng)畫
  @keyframes internalAvatar {
    0%{
      transform: rotate(0deg);
    }
    25%{
      transform: rotate(-90deg);
    }
    50%{
      transform: rotate(-180deg);
    }
    100%{
      transform: rotate(-360deg);
    }
  }

項(xiàng)目地址

上述代碼地址:chat-system

項(xiàng)目克隆到本地后,訪問 http://localhost:8020/login 即可查看效果
本文實(shí)現(xiàn)效果文件路徑:src/views/login.vue

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論