Here's a simple demonstration of how you can create animated progress bar using pure css. The trick is very simple. We need 3 elements, one container and 2 nested elements.
Take a look at the demo | Download zip file
The Concept
We'll put a cool background image in the container and define fixed width and height. First child (SPAN) will act as a progress bar. We'll absolutely position second child (EM) above the progress bar and shift it to the left to a desired value. EM has the same background as the container so it gives an effect of progress bar stopping at certain percentage.

Markup
To keep it as meaningful as possible I used definition list (DL) to list for several values. For single progress bar you can use any element you want. I love paragraphs so I used P in my example.
<dd> <span><em style="left:100px">50%</em></span> </dd>
I decided to use inline styles for left EM placement. It is more convenient to write both values at the same place at once.
Animation
How is it done? Using animated gif of course. Remember those? SPAN has a 200px wide background gif that animates from "zero" to 200px. No matter what percentage we use it goes all the way and stops. Effect of stopping at certain percentage is done with EM as I mentioned earlier.
EM placement
In my example I use 200 pixels wide progress bar. EM element is also 200px wide. So each percentage is 2px wide. If we want to accurately shift the EM we need to multiply percentages with 2.
i.e. 50% will mean 100px left offset, 24% will mean 48px offset, 75% - 150px etc. You get the picture. :)
Designer, developer and a passionate standardista with huge experience in all types of front-end work. I've been featured on numerous css galleries including famous Css Zen Garden official list.
Catar4x on 27 Mar, 2008 wrote:
With only CSS !
Thanks a lot for the script ;)
henri - blog webdesign on 27 Mar, 2008 wrote:
Yves on 27 Mar, 2008 wrote:
But there is still one thing : Is it usefull ? I don't realy think so, you can't calculate any real progression if you have to. And it's very intrusive ... But hey well done !
Peter on 28 Mar, 2008 wrote:
1. what kind of progress bar is it when you cannot control it's progress (once displayed)
2. incorrect usage of definition list, ex: the definition of "Ability to annoy people" is not 80%
cssglobe on 28 Mar, 2008 wrote:
@Peter: Not sure what you mean with incorrect usage if DL? Why exaclty would this be incorrect?
fwolf on 28 Mar, 2008 wrote:
cu, w0lf.
GUESS on 28 Mar, 2008 wrote:
BTM on 30 Mar, 2008 wrote:
cssglobe on 30 Mar, 2008 wrote:
fedmich on 30 Mar, 2008 wrote:
Mauro De Giorgi on 31 Mar, 2008 wrote:
Markavian on 31 Mar, 2008 wrote:
Using CSS for image simple manipulation (cropping), like with rollover buttons, and other tricks is a great way to make clean and simple tweaks at the CSS/HTML level without having to reload your graphics editor. I don't think I can see a use for this one though- I'd sooner use javascript to set the values dynamically, and default to a plain-filled results bar if javascript was disabled.
Simon Gow on 31 Mar, 2008 wrote:
this could also be easily modifiable by javascript which makes it cool!
Quevin on 31 Mar, 2008 wrote:
Muralikrishna on 2 Apr, 2008 wrote:
Carlos Fernando Benitez Zapata on 2 Apr, 2008 wrote:
Carlos Fernando Benitez Zapata on 2 Apr, 2008 wrote:
vincent Voyer on 3 Apr, 2008 wrote:
There's nothing but 2 html tags, an animated gif, and the overflow:hidden property here ...
This is not css related but all about animated Gifs.
You should have done something better with small jquery script + 1px width png non animated transparent image + a little html markup (like <span><strong></strong></span>) + make the strong and span width to 0 with css + add a background color to the span + add your background image to the strong + launch script !
Ok this is not pure CSS but at least it's not just an animated gif.
cssglobe on 3 Apr, 2008 wrote:
And it's not just animated gif either... I am using one more element placed ABOVE the animated gif, that is faking the end of progress movement.
Quoka on 4 Apr, 2008 wrote:
div {
width:216px;height:41px;padding: 5px;
background:url(http://cssglobe.com/lab/progress_bar/bg_bar.gif) no-repeat 0 0;
}
div div {
margin: 3px;text-indent:-8000px;
background:url(http://cssglobe.com/lab/progress_bar/bar.gif) no-repeat 0 0;
width: 80%;
}
<div><div>80%</div></div>
Quoka on 4 Apr, 2008 wrote:
<div]<div]80%</div]</div]
Quoka on 4 Apr, 2008 wrote:
(div) (div) 80% (/div) (/div)
Rafael Masoni on 5 Apr, 2008 wrote:
Congratulations!
gwinn on 7 Apr, 2008 wrote:
Micael on 9 Apr, 2008 wrote:
Very good.
Congratulations.
Herbalife on 11 Apr, 2008 wrote:
Jay on 12 Apr, 2008 wrote:
Tanguy on 16 Apr, 2008 wrote:
I love this progress bar, good job. But i would like to do with different color of bar and it's a big job to change or create a new bar with another color.
Thanks a lot for your job.
Max on 20 Apr, 2008 wrote:
And then you say, hey, what about ppl who dont have the flash player plugin? Come on! Who dont have it! Btw, you can even publish your animation on flash4
David Blanchet on 24 Apr, 2008 wrote:
cssglobe on 25 Apr, 2008 wrote:
Nima Fatemi on 3 May, 2008 wrote:
John Faulds on 5 May, 2008 wrote:
Seb on 9 May, 2008 wrote:
Web address: www.sebruiz.com
Arun on 14 May, 2008 wrote:
Jack Neary on 16 May, 2008 wrote:
Well done.
sotec software on 21 May, 2008 wrote:
Jeremy on 22 May, 2008 wrote:
Stoik on 24 May, 2008 wrote:
cam filmi on 1 Jun, 2008 wrote:
Jon on 4 Jun, 2008 wrote:
Nice experiment, but not useful.
niladri on 20 Jun, 2008 wrote:
Berthold on 17 Aug, 2008 wrote:
Herbalife on 22 Aug, 2008 wrote:
Douglas on 12 Sep, 2008 wrote:
Tks!
Hideki
tibolan on 26 Nov, 2008 wrote:
pinksoler on 9 Dec, 2008 wrote:
i can't use it
sura1 on 10 Dec, 2008 wrote:
May I take the liberty of translate your article from English to German and explain it in my blog Sura 1 Artworks?
Many thanks in advance!
Sura 1
HerbalDistribuidor on 12 Dec, 2008 wrote:
blues on 8 Jan, 2009 wrote:
vexorian on 22 Feb, 2009 wrote:
rduke15 on 11 Mar, 2009 wrote:
Hassan on 15 Mar, 2009 wrote:
Really good stuff here but one problem :
Why the progress bar cannot be printed with the page ?
Nathan on 5 Apr, 2009 wrote:
Craig Beaumont on 15 Apr, 2009 wrote: