Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使进度条以百分比为中心_Javascript_Jquery_Html_Css_Twitter Bootstrap 3 - Fatal编程技术网

Javascript 如何使进度条以百分比为中心

Javascript 如何使进度条以百分比为中心,javascript,jquery,html,css,twitter-bootstrap-3,Javascript,Jquery,Html,Css,Twitter Bootstrap 3,我的问题是百分比100%并不完全在中间。我尝试在JavaScript中隔开它,但它不起作用 电流输出: JavaScript: var progress = setInterval(function () { var $bar = $('.bar'); if ($bar.width() >= 550) { clearInterval(progress); $('.progress').removeClass('active');

我的问题是百分比
100%
并不完全在中间。我尝试在JavaScript中隔开它,但它不起作用

电流输出:

JavaScript:

var progress = setInterval(function () {
    var $bar = $('.bar');

    if ($bar.width() >= 550) {
        clearInterval(progress);
        $('.progress').removeClass('active');
    } else {
        $bar.width($bar.width() + 55);
    }
    $bar.text($bar.width() / 5.5 + "%  ");
}, 800);
107.2727%
看看这个

jQuery

var progress = setInterval(function () {
    var $bar = $('.bar');

    if ($bar.width() >= 520) {
        clearInterval(progress);
        $('.progress').removeClass('active');
        $bar.text("100%");        
    } else {
        $bar.width($bar.width() + 50);
        $bar.text($bar.width() / 5 + "%");
    }

}, 800);
CSS

.bar{
   max-width:520px;    
}
.bar{
   max-width:520px;    
}