您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關(guān)怎么用純CSS 實(shí)現(xiàn)一個(gè)沒有DOM元素的動(dòng)畫效果的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。
代碼解讀
沒有dom元素,直接寫css。
設(shè)置頁面空間:
body{
position:fixed;
margin:0;
width:100vw;
height:100vh;
}
用偽元素設(shè)置背景圖案:
body::before{
content:'';
position:fixed;
width:200vmax;
height:200vmax;
background-color:steelblue;
color:turquoise;
background-image:
linear-gradient(
45deg,
currentColor25%,
transparent25%,transparent75%,
currentColor75%),
linear-gradient(
45deg,
currentColor25%,
transparent25%,transparent75%,
currentColor75%);
background-position:00,5vmax5vmax;
background-size:10vmax10vmax;
平移背景圖案:
body::before{
top:50%;
left:50%;
animation:
9smoveinfiniteease-in-outalternate;
}
@keyframesmove{
from{
left:-40%;
top:-40%;
}
to{
left:-60%;
top:-60%;
}
}
讓背景圖案轉(zhuǎn)動(dòng)起來:
body::before{
animation:
9smoveinfiniteease-in-outalternate,
9s-1.5srotatinginfiniteease-in-outalternate;
}
@keyframesrotating{
to{
transform:rotate(180deg);
}
}
平移頁面:
body{
top:50%;
left:50%;
animation:
3smoveinfiniteease-in-outalternate;
}
縮放頁面:
body{
animation:
3smoveinfiniteease-in-outalternate,
3szoominfiniteease-in-outalternate;
}
@keyframeszoom{
to{
transform:scale(10);
}
}
最后,增加變色效果:
@keyframesrotating{
to{
transform:rotate(180deg);
filter:hue-rotate(1turn);
}
}
大功告成!
感謝各位的閱讀!關(guān)于“怎么用純CSS 實(shí)現(xiàn)一個(gè)沒有DOM元素的動(dòng)畫效果”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。