Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery progress bar - adding Text and changing background color

I am thinking of using the Jquery progress bar to show the progress the user has made in a course.

  • Within the progress bar, I want to show the text Course Progress 70%
  • And I want to change the default grey color of the progress bar

This is what I have done so far - which lets me add the text in the center of the progress bar:

$(function() {
    $( "#progressbar" ).progressbar({
        value: 70
    });
);


<div style="width:600px;" id="progressbar">
    <div style="float:left;color:black;text-align:center;width:100%;padding-top:3px;">Course Progress
</div>

But I cant figure out how to change the color. It doesn't have to change dynamically - just one color that is not grey :)

Thanks

like image 275
Gublooo Avatar asked Dec 27 '22 00:12

Gublooo


1 Answers

Presuming you're using jQueryUI, the progress bar's background controlled by a CSS attribute - it's a solid image.

The style attribute is .ui-widget-header, so you'd want to change the background image for that. In the head of your document, (or if you don't have access to the head, then the body will do) put the following if you want a fancy background image:

<style type='text/css'>
    .ui-widget-header {
        background-image: url('link-to-a-new-gradient-bar-here.png') !important;
    }
</style>

or alternatively, for a simple single-colour background:

<style type='text/css'>
    .ui-widget-header {
        background-image: none !important;
        background-color: #FF0000 !important; //Any colour can go here
    }
</style>

The !important is necessary to make sure the new style overwrites the existing CSS.

Also, you're missing an end tag on your progress bar HTML.

like image 152
Death Avatar answered Feb 15 '23 13:02

Death