您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關css3如何實現(xiàn)圓形旋轉(zhuǎn)倒計時,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
很多答題的H5界面上有旋轉(zhuǎn)倒計時的效果,一個不斷旋轉(zhuǎn)減少的動畫,類似于下圖的這樣。
今天研究了下,可以通過border旋轉(zhuǎn)得到。一般我們可以通過border得到一個四段圓。
See the Pen circle by stoneniqiu (@stoneniqiu) on CodePen.
接下來接可以通過旋轉(zhuǎn)的方式形成一個倒計時的效果:
See the Pen circle-rotate by stoneniqiu (@stoneniqiu) on CodePen.
一開始旋轉(zhuǎn)45度是為了讓半圓剛好立起來。然后旋轉(zhuǎn)一百八十度。
.rightcircle{ border-top: .4rem solid #8731fd; border-right: .4rem solid #8731fd; right: 0; transform: rotate(45deg) } .right_cartoon { -webkit-animation: circleProgressLoad_right 10s linear infinite forwards; animation: circleProgressLoad_right 10s linear infinite forwards; } @keyframes circleProgressLoad_right { 0% { -webkit-transform: rotate(46deg); transform: rotate(46deg) } 50%,to { -webkit-transform: rotate(-136deg); transform: rotate(-136deg) } }
畢竟不是真正的減少,要出現(xiàn)一種顏色占大多數(shù)就可以通過兩個半圓來拼湊。
See the Pen circle-timer by stoneniqiu (@stoneniqiu) on CodePen.
@keyframes circleProgressLoad_left { 0%,50% { -webkit-transform: rotate(46deg); transform: rotate(46deg) } to { -webkit-transform: rotate(-136deg); transform: rotate(-136deg) } }
注意到是右邊線轉(zhuǎn)5秒,然后左邊再等五秒,這里css動畫的效果略有不同,右邊是0%開始,50%,to。左邊是0%,50%,然后to,這樣實現(xiàn)的5秒等待。這就是旋轉(zhuǎn)倒計時的效果,最后還可以通過修改左半環(huán)border-left的顏色,來凸顯最后幾秒鐘的緊急情況。
關于“css3如何實現(xiàn)圓形旋轉(zhuǎn)倒計時”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。