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

css3 實現(xiàn)icon刷新轉(zhuǎn)動效果

  發(fā)布時間:2025-02-19 16:51:37   作者:正在畫圖的小瓶蓋   我要評論
本文給大家介紹css3 實現(xiàn)icon刷新轉(zhuǎn)動效果,文章開頭給大家介紹了webkit-transform、animation、@keyframes這三個屬性,結(jié)合實例代碼給大家介紹的非常詳細,感興趣的朋友一起看看吧

先了解一下-webkit-transform、animation、@keyframes這三個屬性吧

-webkit-transform 可以實現(xiàn)平移、旋轉(zhuǎn)、縮放和傾斜等效果 有以下幾個屬性

translate(x,y) :元素平移

rotate(angle): 旋轉(zhuǎn)元素 比如0deg到360deg 0度到360度

scale(x,y):縮放元素 x,y分別表示水平和垂直方向的縮放比例

skew(x-angle,y-angle) :傾斜元素,分別表示水平和垂直方向的傾斜角度

animation: name duration timing-function delay iteration-count direction fill-mode play-state;

  • name: 指定動畫的名稱,對應(yīng) @keyframes 中定義的動畫關(guān)鍵幀的名稱。
  • duration: 指定動畫的持續(xù)時間,單位為秒(s)或毫秒(ms)。
  • timing-function: 指定動畫的時間函數(shù),用于控制動畫的速度變化。常見的值有 ease、linear、ease-inease-out、ease-in-out 等。
  • delay: 指定動畫的延遲時間,即動畫開始執(zhí)行前的等待時間,單位為秒(s)或毫秒(ms)。iteration-count: 指定動畫的重復(fù)次數(shù),可以是一個正整數(shù),也可以是 infinite 表示無限循環(huán)。
  • direction: 指定動畫播放的方向,可以是 normal(正向播放)、reverse(反向播放)、alternate(交替正反向播放)、alternate-reverse(交替反正向播放)。
  • fill-mode: 指定動畫執(zhí)行前和執(zhí)行后的樣式,可以是 none、forwards、backwards、both
  • play-state: 指定動畫的播放狀態(tài),可以是 running(運行)或 paused(暫停)。

 @keyframes 定義動畫的關(guān)鍵幀的 比如 想初始狀態(tài) 過度到中間時 結(jié)束時 幾個時間段不同的動畫狀態(tài)

常見 0% 、50%、100%

30%時旋轉(zhuǎn)到100度 ,50%時旋轉(zhuǎn)到180度 ........ rotates是這個動畫的名字 

@keyframes rotates {
? ? 0% { -webkit-transform: rotate(0deg) }
? ? 30% { -webkit-transform: rotate(100deg) }
? ? 50% { -webkit-transform: rotate(180deg) }
? ? 70% { -webkit-transform: rotate(270deg) }
? ? 100% {-webkit-transform: rotate(360deg) }
? }

 簡單寫個例子吧 就一個加載的狀態(tài)

讓這個element組件的icon五角星轉(zhuǎn)起來

<template>
  <div>
    <el-icon :size="29" :class="{'refresh-loading':isRefresh}" @click="loading"><StarFilled /></el-icon>
  </div>
</template>
<script>
import { StarFilled } from "@element-plus/icons-vue";
import { ref } from "vue";
export default {
  setup() {
    const isRefresh = ref(false)
    const loading = ()=>{
        isRefresh.value = !isRefresh.value
    }
    return {
      isRefresh,
      loading
    };
  },
};
</script>
<style lang="less">
  .refresh-loading{
    animation: rotates 1s linear infinite;
  }
  @keyframes rotates {
    0% { -webkit-transform: rotate(0deg) }
    30% { -webkit-transform: rotate(100deg) }
    50% { -webkit-transform: rotate(180deg) }
    70% { -webkit-transform: rotate(270deg) }
    100% {-webkit-transform: rotate(360deg) }
  }
</style>

到此這篇關(guān)于css3 實現(xiàn)icon刷新轉(zhuǎn)動的文章就介紹到這了,更多相關(guān)css3 icon刷新轉(zhuǎn)動內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論