溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

css設(shè)置圖片不停旋轉(zhuǎn)的方法

發(fā)布時(shí)間:2020-11-25 10:22:09 來源:億速云 閱讀:895 作者:小新 欄目:web開發(fā)

這篇文章主要介紹了css設(shè)置圖片不停旋轉(zhuǎn)的方法,具有一定借鑒價(jià)值,需要的朋友可以參考下。希望大家閱讀完這篇文章后大有收獲。下面讓小編帶著大家一起了解一下。

css設(shè)置圖片不停旋轉(zhuǎn)的方法:可以通過使用animation屬性和transform屬性來進(jìn)行設(shè)置,如【-webkit-transform: rotate(360deg);animation: rotation;】。

相關(guān)屬性:

animation動(dòng)畫屬性

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

屬性值:

  • animation-name    指定要綁定到選擇器的關(guān)鍵幀的名稱

  • animation-duration    動(dòng)畫指定需要多少秒或毫秒完成

  • animation-timing-function    設(shè)置動(dòng)畫將如何完成一個(gè)周期

  • animation-delay    設(shè)置動(dòng)畫在啟動(dòng)前的延遲間隔。

  • animation-iteration-count    定義動(dòng)畫的播放次數(shù)。

  • animation-direction    指定是否應(yīng)該輪流反向播放動(dòng)畫。

  • animation-fill-mode    規(guī)定當(dāng)動(dòng)畫不播放時(shí)(當(dāng)動(dòng)畫完成時(shí),或當(dāng)動(dòng)畫有一個(gè)延遲未開始播放時(shí)),要應(yīng)用到元素的樣式。

  • animation-play-state    指定動(dòng)畫是否正在運(yùn)行或已暫停。

  • initial    設(shè)置屬性為其默認(rèn)值。

  • inherit    從父元素繼承屬性。

Transform屬性應(yīng)用于元素的2D或3D轉(zhuǎn)換。這個(gè)屬性允許你將元素旋轉(zhuǎn),縮放,移動(dòng),傾斜等。

transform: none|transform-functions;

屬性值:

  • none    定義不進(jìn)行轉(zhuǎn)換。

  • matrix(n,n,n,n,n,n)    定義 2D 轉(zhuǎn)換,使用六個(gè)值的矩陣。

  • matrix3d(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n)    定義 3D 轉(zhuǎn)換,使用 16 個(gè)值的 4x4 矩陣。

  • translate(x,y)    定義 2D 轉(zhuǎn)換。

  • translate3d(x,y,z)    定義 3D 轉(zhuǎn)換。

代碼實(shí)現(xiàn):

html代碼:

<div class="demo">
    <img class="an img" src="/test/img/2.png" width="500" height="500"/>
</div>

旋轉(zhuǎn)代碼:

.demo{
   text-align: center;
    margin-top: 100px;
}
@-webkit-keyframes rotation{
    from {-webkit-transform: rotate(0deg);}
    to {-webkit-transform: rotate(360deg);}
}
.an{
    -webkit-transform: rotate(360deg);
    animation: rotation 3s linear infinite;
    -moz-animation: rotation 3s linear infinite;
    -webkit-animation: rotation 3s linear infinite;
    -o-animation: rotation 3s linear infinite;
}
.img{border-radius: 250px;}

實(shí)現(xiàn)效果:

css設(shè)置圖片不停旋轉(zhuǎn)的方法

感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享css設(shè)置圖片不停旋轉(zhuǎn)的方法內(nèi)容對(duì)大家有幫助,同時(shí)也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,遇到問題就找億速云,詳細(xì)的解決方法等著你來學(xué)習(xí)!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

css
AI