Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 Transition of HTML5 progress bar element

I am using a progress bar as described here:

http://css-tricks.com/html5-progress-element/

Using the <progress> element and styling it with the pseudo classes -webkit-progress-bar and -webkit-progress-value.

So now I want to animate the progress-value, whenever it updates.

In my theory this should work via transitioning its CSS width attribute like this:

progress::-webkit-progress-value {
    transition: 5s width;
}

But for some reason this does not seem to work.

like image 319
mr.T Avatar asked Jun 25 '14 12:06

mr.T


People also ask

Which is the correct implementation for a progress bar in HTML5?

Use the <progress> tag to create a progress bar in HTML. The HTML <progress> tag specifies a completion progress of a task. It is displayed as a progress bar.

How do I change the progress bar style in HTML?

Thus, to change the progress bar and the progress value styles in these browsers, we need to add those Webkit pseudo-classes . Firefox also has its special pseudo-class that is ::-moz-progress-bar. Unlike Chrome and Safari, this pseudo-class in Firefox refers to the progress meter/value.

What is css3 transition?

CSS transitions provide a way to control animation speed when changing CSS properties. Instead of having property changes take effect immediately, you can cause the changes in a property to take place over a period of time.


1 Answers

The correct syntax for the transition property is:

transition: [property] [duration] [timing-function] [delay];

then your value ( transition: 5s width; ) is wrong, timing and property are inverted, and timing function is missing. It should be (for example):

transition : width 5s ease;

It should also be prefixed to work crossbrowser, especially for WebKit based browsers, leaving the standard property as the last one.

-webkit-transition : width 5s ease;
   -moz-transition : width 5s ease;
     -o-transition : width 5s ease;
        transition : width 5s ease;
like image 188
Andrea Ligios Avatar answered Sep 22 '22 23:09

Andrea Ligios