是否可以让 Bootstrap 进度条每隔 5 秒达到 100%
<div class="progress progress-striped active">
<div class="bar" style="width: 40%;"></div>
</div>
进度条是通过 width 样式填充的,所以上面会把它放在 40% 完成
我如何让它在 5 秒内顺利加载到 100%,然后重新设置为 0 并重新开始,重复进行?
谢谢。
最佳答案
在这个答案中,我稍微修改了@Blender 的方法以永远运行。
为此,我使用了 animate
函数的 complete
参数。
http://jsfiddle.net/xXM2z/490/
完整的 JS 代码:
$(document).ready(function(){
animateScroll();
});
function animateScroll()
{
$('.bar').animate({
width: '100%'
}, {
duration: 5000,
easing: 'linear',
complete:function(){ $(this).css("width","0%");
}
});
animateScroll();
}
关于javascript - Twitter-Bootstrap 进度条每 x 秒 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13104361/