I am trying to create a Bootstrap progress bar with a gradient color fill (such as red to green). Currently, my CSS code looks like this:
.progress-lf {
position: relative;
height: 31px;
background-color: rgba(51, 51, 51, 0.4)
}
.progress-lf span {
position: absolute;
display: block;
font-weight: bold;
color: #d2d2d2;
width: 100%;
top:6px;
}
.progress-lf .gradient {
background-color: transparent;
background-image: -ms-linear-gradient(left, #E34747 0%, #5FB365 100%);
background-image: -moz-linear-gradient(left, #E34747 0%, #5FB365 100%);
background-image: -o-linear-gradient(left, #E34747 0%, #5FB365 100%);
background-image: -webkit-gradient(linear, left top, right top, color-stop(0, #E34747), color-stop(100, #5FB365));
background-image: -webkit-linear-gradient(left, #E34747 0%, #5FB365 100%);
background-image: linear-gradient(to right, #E34747 0%, #5FB365 100%);
}
Here is the corresponding HTML:
<div class="progress progress-lf">
<div class="progress-bar gradient" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo mt_rand(0,100);?>%;">
<span>60% Complete</span>
</div>
</div>
While this displays the gradient, it shows the full color spectrum for the entire length of the progress bar. I am looking for a way to only show the relevant percentage of the color spectrum (e.g., only 60% of the gradient for 60%). Any suggestions on how to achieve this? I would prefer a solution using pure CSS, but jQuery is also an option.