Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use CSS3 transition to animate the value of a meter-tag?

Tags:

html

css

Is it possible with css only to animate the visual change to a meter / progress-tag if the value changed?

Somthing like this

-webkit-transition: all 1s linear;

Or

-webkit-transition: meter-value 1s linear;
like image 666
Christian Tellnes Avatar asked Nov 02 '10 23:11

Christian Tellnes


People also ask

Is it possible to animate an element using CSS?

CSS animations make it possible to animate transitions from one CSS style configuration to another. Animations consist of two components, a style describing the CSS animation and a set of keyframes that indicate the start and end states of the animation's style, as well as possible intermediate waypoints.

What CSS animation transitions can do?

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.

How do you add transition effects in css3?

To make the transition occur, you must specify at least two things — the name of the CSS property to which you want to apply the transition effect using the transition-property CSS property, and the duration of the transition effect (greater than 0) using the transition-duration CSS property.

Is transition and animation are same CSS?

CSS transitions are generally best for simple from-to movements, while CSS animations are for more complex series of movements. It's easy to confuse CSS transitions and animations because they let you do similar things. Here are just a few examples: You can visualize property changes.

When does the transition effect start in CSS?

The transition effect will start when the specified CSS property (width) changes value. Now, let us specify a new value for the width property when a user mouses over the <div> element:

Is there a difference between CSS and HTML meter / progress elements?

When I wrote this, meter / progress elements were webkit-only. No, CSS is meant only to change the presentation of a page, while the value is part of the page's content, and must be specified either directly in HTML or manipulated via JavaScript. Edit: I slightly misunderstood your question, but the answer remains the same.

How do you use CSS animation?

An animation lets an element gradually change from one style to another. You can change as many CSS properties you want, as many times you want. To use CSS animation, you must first specify some keyframes for the animation. Keyframes hold what styles the element will have at certain times.

Is it possible to animate the visual change to a meter/progression-tag?

Is it possible with css only to animate the visual change to a meter / progress-tag if the value changed? Yes it is perfectly possible, because WebKit uses Shadow DOM to materialize the meter element instead of using default system one (so the meter ans progress bar can be styled).


2 Answers

Yes it is perfectly possible, because WebKit uses Shadow DOM to materialize the meter element instead of using default system one (so the meter ans progress bar can be styled). You can figure this as an hidden content inside the meter element :

<div pseudo="-webkit-meter-inner-element">
    <div pseudo="-webkit-meter-bar">
        <div pseudo="-webkit-meter-optimum-value" style="width: 46%;"></div>
    </div>
</div>

When you change the value of your meter, WebKit will change the width of the last div. So with :

meter::-webkit-meter-optimum-value, meter::-webkit-meter-suboptimum-value, meter::-webkit-meter-even-less-good-value {
    transition: 1s width;
}

You can animate your meter.

like image 71
leops Avatar answered Sep 23 '22 16:09

leops


No, CSS is meant only to change the presentation of a page, while the value is part of the page's content, and must be specified either directly in HTML or manipulated via JavaScript.

Edit: I slightly misunderstood your question, but the answer remains the same. CSS transitions are meant to animate CSS properties only, and it isn't possible to access an element's value from CSS.

like image 20
casablanca Avatar answered Sep 22 '22 16:09

casablanca