简体   繁体   English

如何使进度条百分比居中

[英]How to make the progress bar percent centered

My problem is the percent 100% is not exactly in the center. 我的问题是100%不在中心。 I tried spacing it in the JavaScript, but it's not working. 我尝试在JavaScript中将其隔开,但无法正常工作。

Current output: http://jsfiddle.net/GZSH6/53/ 当前输出: http : //jsfiddle.net/GZSH6/53/

在此处输入图片说明

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);

Take a look at this DEMO 看看这个演示

jQuery 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 CSS

.bar{
   max-width:520px;    
}
<div style="width: 590px;text-align:left;text-indent:202px" class="bar">107.27272727272727%</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM