十年網(wǎng)站開(kāi)發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無(wú)憂售后,網(wǎng)站問(wèn)題一站解決
使用純CSS實(shí)現(xiàn)一個(gè)圓環(huán)旋轉(zhuǎn)錯(cuò)覺(jué)的動(dòng)畫(huà)效果?這個(gè)問(wèn)題可能是我們?nèi)粘W(xué)習(xí)或工作經(jīng)常見(jiàn)到的。希望通過(guò)這個(gè)問(wèn)題能讓你收獲頗深。下面是小編給大家?guī)?lái)的參考內(nèi)容,讓我們一起來(lái)看看吧!


https://github.com/comehope/front-end-daily-challenges
代碼解讀定義 dom,容器中包含 10 個(gè) 定義容器尺寸: 定義子元素的尺寸,和容器相同: 在子元素的正中畫(huà)一個(gè)黃色的小方塊: 增加讓小方塊左右移動(dòng)的動(dòng)畫(huà)效果,動(dòng)畫(huà)時(shí)長(zhǎng)還會(huì)在后面用到,所以定義成變量: 用貝賽爾曲線調(diào)整動(dòng)畫(huà)的時(shí)間函數(shù),使小方塊看起來(lái)就像在左右兩側(cè)跳來(lái)跳去: 增加小方塊變形的動(dòng)畫(huà),使它看起來(lái)有下蹲起跳的擬人效果: 至此,完成了 1 個(gè)方塊的動(dòng)畫(huà)。接下來(lái)設(shè)置多個(gè)方塊的動(dòng)畫(huà)效果。 為子元素定義 CSS 下標(biāo)變量: 旋轉(zhuǎn)子元素,使小方塊分布均勻地在容器的四周,圍合成一個(gè)圓形: 設(shè)置動(dòng)畫(huà)延時(shí),現(xiàn)在看起來(lái)就像是一群小方塊貼著一個(gè)圓的內(nèi)邊線在旋轉(zhuǎn)了(但實(shí)際上沒(méi)有任何元素在做旋轉(zhuǎn)運(yùn)動(dòng),大腦感覺(jué)到的旋轉(zhuǎn)是一種錯(cuò)覺(jué)): 最后,為小方塊上色: 感謝各位的閱讀!看完上述內(nèi)容,你們對(duì)使用純CSS實(shí)現(xiàn)一個(gè)圓環(huán)旋轉(zhuǎn)錯(cuò)覺(jué)的動(dòng)畫(huà)效果大概了解了嗎?希望文章內(nèi)容對(duì)大家有所幫助。如果想了解更多相關(guān)文章內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)網(wǎng)站制作公司行業(yè)資訊頻道。子元素:.container {
width: 17em;
height: 17em;
font-size: 16px;
}.container {
position: relative;
}
.container div {
position: absolute;
width: inherit;
height: inherit;
}.container div {
display: flex;
align-items: center;
justify-content: center;
}
.container span {
position: absolute;
width: 1em;
height: 1em;
background-color: yellow;
}.container span {
--duration: 2s;
animation: move var(--duration) infinite;
}
@keyframes move {
0%, 100% {
left: calc(10% - 0.5em);
}
50% {
left: calc(90% - 0.5em);
}
}.container span {
animation: move var(--duration) cubic-bezier(0.6, -0.3, 0.7, 0) infinite;
}.container span {
animation:
move var(--duration) cubic-bezier(0.6, -0.3, 0.7, 0) infinite,
morph var(--duration) ease-in-out infinite;
}
@keyframes morph {
0%, 50%, 100% {
transform: scale(0.75, 1);
}
25%, 75% {
transform: scale(1.5, 0.5);
}
}.container div:nth-child(1) { --n: 1; }
.container div:nth-child(2) { --n: 2; }
.container div:nth-child(3) { --n: 3; }
.container div:nth-child(4) { --n: 4; }
.container div:nth-child(5) { --n: 5; }
.container div:nth-child(6) { --n: 6; }
.container div:nth-child(7) { --n: 7; }
.container div:nth-child(8) { --n: 8; }
.container div:nth-child(9) { --n: 9; }.container p {
transform: rotate(calc(var(--n) * 40deg));
}.container span {
animation-delay: calc(var(--duration) / 9 * var(--n) * -1);
}.container span {
background-color: hsl(calc(var(--n) * 80deg), 100%, 70%);
}
文章題目:使用純CSS實(shí)現(xiàn)一個(gè)圓環(huán)旋轉(zhuǎn)錯(cuò)覺(jué)的動(dòng)畫(huà)效果-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)路徑:http://m.jiaotiyi.com/article/dccpeg.html