如何创建仅 CSS 的进度指示器并在特定百分比处停止?
仅使用 CSS 在特定百分比停止的进度指示器
您已在此网站上搜索过进度条,但您搜索过的进度条我们发现所有的动画圈子都达到了100%。但是,您有兴趣创建一个在特定百分比处停止的进度条,如下面的屏幕截图中显示的那样。
要仅使用 CSS 实现此效果,您可以结合使用剪辑和动画技术。以下面的小提琴为例:
.wrapper { width: 100px; /* Set the size of the progress bar */ height: 100px; position: absolute; /* Enable clipping */ clip: rect(0px, 100px, 100px, 50px); /* Hide half of the progress bar */ } /* Set the sizes of the elements that make up the progress bar */ .circle { width: 80px; height: 80px; border: 10px solid green; border-radius: 50px; position: absolute; clip: rect(0px, 50px, 100px, 0px); } /* Using the data attributes for the animation selectors. */ /* Base settings for all animated elements */ div[data-anim~=base] { -webkit-animation-iteration-count: 1; /* Only run once */ -webkit-animation-fill-mode: forwards; /* Hold the last keyframe */ -webkit-animation-timing-function:linear; /* Linear animation */ } .wrapper[data-anim~=wrapper] { -webkit-animation-duration: 0.01s; /* Complete keyframes asap */ -webkit-animation-delay: 3s; /* Wait half of the animation */ -webkit-animation-name: close-wrapper; /* Keyframes name */ } .circle[data-anim~=left] { -webkit-animation-duration: 6s; /* Full animation time */ -webkit-animation-name: left-spin; } .circle[data-anim~=right] { -webkit-animation-duration: 3s; /* Half animation time */ -webkit-animation-name: right-spin; } /* Rotate the right side of the progress bar from 0 to 180 degrees */ @-webkit-keyframes right-spin { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(180deg); } } /* Rotate the left side of the progress bar from 0 to 360 degrees */ @-webkit-keyframes left-spin { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(360deg); } } /* Set the wrapper clip to auto, effectively removing the clip */ @-webkit-keyframes close-wrapper { to { clip: rect(auto, auto, auto, auto); } }
登录后复制
<div class="wrapper" data-anim="base wrapper"> <div class="circle" data-anim="base left"></div> <div class="circle" data-anim="base right"></div> </div>
登录后复制
在此小提琴中,采用剪裁、圆形元素和动画的组合来创建所需的效果。通过使用 Clip 属性隐藏一半进度条,然后对圆形元素的不同部分进行动画旋转,就可以实现在特定百分比处停止的进度条。
以上是如何创建仅 CSS 的进度指示器并在特定百分比处停止?的详细内容。更多信息请关注PHP中文网其他相关文章!
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章
刺客信条阴影:贝壳谜语解决方案
1 个月前
By DDD
Windows 11 KB5054979中的新功能以及如何解决更新问题
3 周前
By DDD
在哪里可以找到原子中的起重机控制钥匙卡
1 个月前
By DDD
如何修复KB5055523无法在Windows 11中安装?
2 周前
By DDD
Inzoi:如何申请学校和大学
3 周前
By DDD

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

关于Flex布局中紫色斜线区域的疑问在使用Flex布局时,你可能会遇到一些令人困惑的现象,比如在开发者工具(d...
