用CSS3如何设计一个圆弧动态的倒计时功能
发布时间:2023-09-23 14:46:34 所属栏目:语言 来源:
导读:今天研究了下,可以通过border旋转得到。一般我们可以通过border得到一个四段圆。
See the Pen circle by stoneniqiu (@stoneniqiu) on CodePen.
接下来接可以通过旋转的方式形成一个倒计时的效果:
Se
See the Pen circle by stoneniqiu (@stoneniqiu) on CodePen.
接下来接可以通过旋转的方式形成一个倒计时的效果:
Se
今天研究了下,可以通过border旋转得到。一般我们可以通过border得到一个四段圆。 See the Pen circle by stoneniqiu (@stoneniqiu) on CodePen. 接下来接可以通过旋转的方式形成一个倒计时的效果: See the Pen circle-rotate by stoneniqiu (@stoneniqiu) on CodePen. 一开始旋转45度是为了让半圆刚好立起来。然后旋转一百八十度。 .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) } } 毕竟不是真正的减少,要出现一种颜色占大多数就可以通过两个半圆来拼凑。 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) } } 注意到是右边线转5秒,然后左边再等五秒,这里css动画的效果略有不同,右边是0%开始,50%,to。左边是0%,50%,然后to,这样实现的5秒等待。这就是旋转倒计时的效果,最后还可以通过修改左半环border-left的颜色,来凸显最后几秒钟的紧急情况。 (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐