使用css3实现条形进度条效果原理
首先实用html构建所需的两个div,利用position:absolute使得两个div重合,根据要求区别不一样的颜色。
利用keyframe属性使得重合的进度条移动起来,再用animation进行动画控制,语法为@keyframes animationname {keyframes-selector {css-styles;}}
ps:如果有对以上知识不了解的小伙伴请查阅本站的相关文章。
如何使用css3实现图片的自动轮播特效(附完整代码)
使用css3实现条形进度条效果代码
<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd"><html><head><title> new document </title><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta name="viewport" content="initial-scale=1"><style>.process-bar{ width:100px; display:inline-block; *zoom:1;}.pb-wrapper{ border:1px solid #cfd0d2; position:relative; background:#cfd0d2; border-radius: 8px;}.pb-container{ height:12px; position:relative; left:-1px; margin-right:-2px; font:1px/0 arial; padding:1px;}.pb-highlight{ position:absolute; left:0; top:0; _top:1px; width:100%; opacity:0.6; filter:alpha(opacity=60); height:6px; background:white; font-size:1px; line-height:0; z-index:1}.pb-text{ width:100%; position:absolute; left:0; top:0; text-align:center; font:10px/12px arial; color:black; font:10px/12px arial}</style></head><body> <div class="process-bar skin-green"> <div class="pb-wrapper"> <div class="pb-highlight"></div> <div class="pb-container"> <div class="pb-text">50%</div> <div class="pb-value" style="height: 100%;width: 50%;background: #19d73d;border-radius: 8px;"></div> </div> </div> </div></body></html>
效果如图所示
以上就是如何使用css3实现条形进度条效果(附完整代码)的详细内容。
