Considering the title, here's an example scenario:
Imagine a setup where 80% is represented by the green bar and 90% by the darker grey bar. However, due to some coding complications, I couldn't display the 90% on the right side of the bar as intended. Instead, I had to manually edit it using Paint.
Currently, I have been utilizing the following code structure for this progress bar:
HTML:
<div id='progBar'>
<div>
<div>
</div>
</div>
</div>
JS: progress:
function (percent, current, $element) {
var progressBarWidth = percent * $element.width() / 100;
var currentBarWidth = current * $element.width() / 100;
$element.find('div').animate({ width: progressBarWidth }, 2000);
$element.find('div div').animate({ width: currentBarWidth }, 2000);
}
CSS:
#progBar {
width: 275px;
height: 20px;
border: 1px solid #BDBDBD;
background-color: #F2F2F2;
margin: 2px 0 0 4px;
line-height: 13px;
font-size: 10px;
text-align: right;
color: #000;
}
#progBar div {
height: 100%;
color: #fff;
text-align: right;
line-height: 25px;
width: 0;
background-color: #D8D8D8;
}
#progBar div div {
height: 40%;
border: 1px solid #BDBDBD;
background-color: #b4d134;
margin-top: 6px;
line-height: 13px;
font-size: 10px;
text-align: left;
color: #000;
}
The first div bar with id Progbar represents the entire progress bar. The second block refers to the primary (darker grey) progress bar, while the third block denotes the secondary green bar.
Although the code seems to be functioning well, my issue arises when attempting to showcase the percentage on the far right end of the progress bar (the 90%). It appears that the stacking of several div blocks in one line might be causing this discrepancy.
Is there an alternative approach to aligning my progress bar similar to the above depiction? I prefer not to arrange two separate bars side by side but rather stack them precisely like the image shown above.
UPDATE: Upon executing these lines of code below,
$element.find('div').animate({ width: progressBarWidth }, 2000).html(target + "% ");
$element.find('div div').animate({ width: currentBarWidth }, 2000).html(current + "% ");
The current percentage displays correctly on the left side, yet the target percentage on the right side fails to do so...