I’ve recently come up with a simple way to make a decent looking, css colorable progress bar/meter out of a couple divs and an image. This is what mine looks like:
Basically, you have three divs: a container for the grey, non ‘populated’ section, a div for the colored value, and a div for the text. Both the container and the value div have your image as a background. This image uses mad awesome png transparency to show some of the div’s background color through.
HTML
The HTML is simple:
<div class="meter-wrap">
<div class="meter-value" style="background-color: #0a0; width: 40%;">
<div class="meter-text">
Text Here!
</div>
</div>
</div>
Notice the style attribute in the .meter-value div. The background color is the color of the progress bar, and the width is set to the percentage of progress. Easy peasy.
CSS
Oh yes, in all of its glory:
.meter-wrap{
position: relative;
}
.meter-wrap, .meter-value, .meter-text {
/* The width and height of your image */
width: 155px; height: 30px;
}
.meter-wrap, .meter-value {
background: #bdbdbd url(/path/to/your-image.png) top left no-repeat;
}
.meter-text {
position: absolute;
top:0; left:0;
padding-top: 5px;
color: #fff;
text-align: center;
width: 100%;
}
The Image
Here is my image. I’ve placed it on a colored background so you can see the corners. It simply has completely opaque white corners, and uses a gradient for the center that goes from transparent white to completely transparent. An image like this is very easy to construct in a vector drawing application such as Inkscape .
Examples with JavaScript!
Now, so you can see what it can do, I’ve put together a couple of super rad jQuery examples.
Click the bar below to see the it go from 0% to 100%! Coooooool!
Or maybe this one that runs through a range of colors.






Discuss
Cool this was the easiest way to achieve a static progress bar I wanted to create. Thanks
Thank you for this. It’s simple, yet elegant. Exactly what I needed.
This is awesome. Thanks for sharing.
Doesn’t work in evil browsers :-/
where’s the js that makes the button clicks work?
The button click js is in an inline script element in the page source. I would post it in this comment, but WP will hose the formatting. View the source and ctrl+f for “$(’#meter-ex1′).click”.
The evil browser I am not so concerned about. ie6 has issues with png transparency. There is a jquery plugin called supersleight that can help alleviate the transparent png issues.
If you apply white-space: nowrap to the value and text containers it won’t wrap the text when the meter is at 0% in evil browsers. Aside from that, if you can find a good png fix this technique works great in evil browsers! Thanks!
Hello,
I’ve implemented another progress bar widget as a jquery plugin based on your implementation: http://blog.felipel.com/post/JQuery-progress-bar-slider-plugin.aspx
Thought you’d like to know!
Felipe
Interesting example - is there anyway you can provide the actual image used in the demo. I’ve been trying to create the necessary image - but so far haven’t been able to create an image correctly to make the demo work.
Awesome! What an excellent author’s imagination!