CSS: Animation vs. Transition
So, I understand how to perform both CSS3 transitions and animations. What is not clear, and I've googled, is when to use which.
For example, if I want to make a ball bounce, it is clear that animation is the way to go. I could provide keyframes and the browser would do the intermediates frames and I'll have a nice animation going.
However, there are cases when a said effect can be achieved either way. A simple and common example would be implement the facebook style sliding drawer menu:
This effect can be achieved through transitions like so:
.sf-page {
-webkit-transition: -webkit-transform .2s ease-out;
}
.sf-page.out {
-webkit-transform: translateX(240px);
}
http://jsfiddle.net/NwEGz/
Or, through animations like so:
.sf-page {
-webkit-animation-duration: .4s;
-webkit-transition-timing-function: ease-out;
}
.sf-page.in {
-webkit-animation-name: sf-slidein;
-webkit-transform: translate3d(0, 0, 0);
}
.sf-page.out {
-webkit-animation-name: sf-slideout;
-webkit-transform: translateX(240px);
}
@-webkit-keyframes sf-slideout {
from { -webkit-transform: translate3d(0, 0, 0); }
to { -webkit-transform: translate3d(240px, 0, 0); }
}
@-webkit-keyframes sf-slidein {
from { -webkit-transform: translate3d(240px, 0, 0); }
to { -webkit-transform: translate3d(0, 0, 0); }
}
http://jsfiddle.net/4Z5Mr/
With HTML that looks like so:
<div class="sf-container">
<div class="sf-page in" id="content-container">
<button type="button">Click Me</button>
</div>
<div class="sf-drawer">
</div>
</div>
And, this accompanying jQuery script:
$("#content-container").click(function(){
$("#content-container").toggleClass("out");
// below is only required for css animation route
$("#content-container").toggleClass("in");
});
What I'd like to understand is what are the pros and cons of these approaches.
- One obvious difference is that animating is taking a whole lot more code.
- Animation gives better flexibility. I can have different animation for sliding out and in
- Is there something that can be said about performance. Do both take advantage of h/w acceleration?
- Which is more modern and the way going forward
- Anything else you could add?
css css3 css-transitions css-animations
add a comment |
So, I understand how to perform both CSS3 transitions and animations. What is not clear, and I've googled, is when to use which.
For example, if I want to make a ball bounce, it is clear that animation is the way to go. I could provide keyframes and the browser would do the intermediates frames and I'll have a nice animation going.
However, there are cases when a said effect can be achieved either way. A simple and common example would be implement the facebook style sliding drawer menu:
This effect can be achieved through transitions like so:
.sf-page {
-webkit-transition: -webkit-transform .2s ease-out;
}
.sf-page.out {
-webkit-transform: translateX(240px);
}
http://jsfiddle.net/NwEGz/
Or, through animations like so:
.sf-page {
-webkit-animation-duration: .4s;
-webkit-transition-timing-function: ease-out;
}
.sf-page.in {
-webkit-animation-name: sf-slidein;
-webkit-transform: translate3d(0, 0, 0);
}
.sf-page.out {
-webkit-animation-name: sf-slideout;
-webkit-transform: translateX(240px);
}
@-webkit-keyframes sf-slideout {
from { -webkit-transform: translate3d(0, 0, 0); }
to { -webkit-transform: translate3d(240px, 0, 0); }
}
@-webkit-keyframes sf-slidein {
from { -webkit-transform: translate3d(240px, 0, 0); }
to { -webkit-transform: translate3d(0, 0, 0); }
}
http://jsfiddle.net/4Z5Mr/
With HTML that looks like so:
<div class="sf-container">
<div class="sf-page in" id="content-container">
<button type="button">Click Me</button>
</div>
<div class="sf-drawer">
</div>
</div>
And, this accompanying jQuery script:
$("#content-container").click(function(){
$("#content-container").toggleClass("out");
// below is only required for css animation route
$("#content-container").toggleClass("in");
});
What I'd like to understand is what are the pros and cons of these approaches.
- One obvious difference is that animating is taking a whole lot more code.
- Animation gives better flexibility. I can have different animation for sliding out and in
- Is there something that can be said about performance. Do both take advantage of h/w acceleration?
- Which is more modern and the way going forward
- Anything else you could add?
css css3 css-transitions css-animations
add a comment |
So, I understand how to perform both CSS3 transitions and animations. What is not clear, and I've googled, is when to use which.
For example, if I want to make a ball bounce, it is clear that animation is the way to go. I could provide keyframes and the browser would do the intermediates frames and I'll have a nice animation going.
However, there are cases when a said effect can be achieved either way. A simple and common example would be implement the facebook style sliding drawer menu:
This effect can be achieved through transitions like so:
.sf-page {
-webkit-transition: -webkit-transform .2s ease-out;
}
.sf-page.out {
-webkit-transform: translateX(240px);
}
http://jsfiddle.net/NwEGz/
Or, through animations like so:
.sf-page {
-webkit-animation-duration: .4s;
-webkit-transition-timing-function: ease-out;
}
.sf-page.in {
-webkit-animation-name: sf-slidein;
-webkit-transform: translate3d(0, 0, 0);
}
.sf-page.out {
-webkit-animation-name: sf-slideout;
-webkit-transform: translateX(240px);
}
@-webkit-keyframes sf-slideout {
from { -webkit-transform: translate3d(0, 0, 0); }
to { -webkit-transform: translate3d(240px, 0, 0); }
}
@-webkit-keyframes sf-slidein {
from { -webkit-transform: translate3d(240px, 0, 0); }
to { -webkit-transform: translate3d(0, 0, 0); }
}
http://jsfiddle.net/4Z5Mr/
With HTML that looks like so:
<div class="sf-container">
<div class="sf-page in" id="content-container">
<button type="button">Click Me</button>
</div>
<div class="sf-drawer">
</div>
</div>
And, this accompanying jQuery script:
$("#content-container").click(function(){
$("#content-container").toggleClass("out");
// below is only required for css animation route
$("#content-container").toggleClass("in");
});
What I'd like to understand is what are the pros and cons of these approaches.
- One obvious difference is that animating is taking a whole lot more code.
- Animation gives better flexibility. I can have different animation for sliding out and in
- Is there something that can be said about performance. Do both take advantage of h/w acceleration?
- Which is more modern and the way going forward
- Anything else you could add?
css css3 css-transitions css-animations
So, I understand how to perform both CSS3 transitions and animations. What is not clear, and I've googled, is when to use which.
For example, if I want to make a ball bounce, it is clear that animation is the way to go. I could provide keyframes and the browser would do the intermediates frames and I'll have a nice animation going.
However, there are cases when a said effect can be achieved either way. A simple and common example would be implement the facebook style sliding drawer menu:
This effect can be achieved through transitions like so:
.sf-page {
-webkit-transition: -webkit-transform .2s ease-out;
}
.sf-page.out {
-webkit-transform: translateX(240px);
}
http://jsfiddle.net/NwEGz/
Or, through animations like so:
.sf-page {
-webkit-animation-duration: .4s;
-webkit-transition-timing-function: ease-out;
}
.sf-page.in {
-webkit-animation-name: sf-slidein;
-webkit-transform: translate3d(0, 0, 0);
}
.sf-page.out {
-webkit-animation-name: sf-slideout;
-webkit-transform: translateX(240px);
}
@-webkit-keyframes sf-slideout {
from { -webkit-transform: translate3d(0, 0, 0); }
to { -webkit-transform: translate3d(240px, 0, 0); }
}
@-webkit-keyframes sf-slidein {
from { -webkit-transform: translate3d(240px, 0, 0); }
to { -webkit-transform: translate3d(0, 0, 0); }
}
http://jsfiddle.net/4Z5Mr/
With HTML that looks like so:
<div class="sf-container">
<div class="sf-page in" id="content-container">
<button type="button">Click Me</button>
</div>
<div class="sf-drawer">
</div>
</div>
And, this accompanying jQuery script:
$("#content-container").click(function(){
$("#content-container").toggleClass("out");
// below is only required for css animation route
$("#content-container").toggleClass("in");
});
What I'd like to understand is what are the pros and cons of these approaches.
- One obvious difference is that animating is taking a whole lot more code.
- Animation gives better flexibility. I can have different animation for sliding out and in
- Is there something that can be said about performance. Do both take advantage of h/w acceleration?
- Which is more modern and the way going forward
- Anything else you could add?
css css3 css-transitions css-animations
css css3 css-transitions css-animations
edited Dec 14 '13 at 19:58
Zentaurus
5361824
5361824
asked Dec 14 '13 at 17:28
Code PoetCode Poet
5,623185490
5,623185490
add a comment |
add a comment |
7 Answers
7
active
oldest
votes
It looks like you've got a handle on how to do them, just not when to do them.
A transition is an animation, just one that is performed between two distinct states - i.e. a start state and an end state. Like a drawer menu, the start state could be open and the end state could be closed, or vice versa.
If you want to perform something that does not specifically involve a start state and an end state, or you need more fine grain control over the keyframes in a transition, then you've got to use an animation.
5
check out this article too kirupa.com/html5/css3_animations_vs_transitions.htm , it correctly points out that transitions are the way to go when doing javascript interactions.
– Scott Jungwirth
Jun 22 '15 at 17:27
add a comment |
I'll let the definitions speak for themselves (according to Merriam-Webster):
Transition: A movement, development, or evolution from one form, stage, or style to another
Animation: Endowed with life or the qualities of life; full of movement
The names appropriately fit their purposes in CSS
So, the example you gave should use transitions because it is only a change from one state to another
add a comment |
Animation takes a lot more code unless you're using the same transition over and over, in which case an animation would be better.
You can have different effects for sliding in and out without an animation. Just have a different transition on both the original rule and the modified rule:
.two-transitions {
transition: all 50ms linear;
}
.two-transitions:hover {
transition: all 800ms ease-out;
}
Animations are just abstractions of transitions, so if the transition is hardware accelerated, the animation will be. It makes no difference.
Both are very modern.
My rule of thumb is if I use the same transition three times, it should probably be an animation. This is easier to maintain and alter in the future. But if you are only using it once, it is more typing to make the animation and maybe not worth it.
I should also add that animations have keyframes, allowing you to do very complex and controlled progressions, which is kind of amazing.
– paulcpederson
Dec 15 '13 at 6:43
add a comment |
Animations are just that - a smooth behavior of set of properties. In other words it specifies what should happen to a set of element's properties. You define an animation and describe how this set of properties should behave during the animation process.
Transitions on the other side specify how a property (or properties) should perform their change. Each change. Setting a new value for certain property, be it with JavaScript or CSS, is always a transition, but by default it is not smooth. By setting transition in the css style you define different (smooth) way to perform these changes.
It can be said that transitions define a default animation that should be performed every time the specified property has changed.
1
I disagree with this definition as both specify how and what
– Zach Saucier
Jul 31 '14 at 2:12
add a comment |
A shorter answer, straight on point:
Transition:
- Needs a triggering element (:hover, :focus etc.)
- Only 2 animation states (start and end)
- Used for simpler animations (buttons, dropdown menus and so on)
- Easier to create but not so many animation/effect possibilities
Animation @keyframes:
- It can be used for endless animations
- Can set more than 2 states
- No boundaries
Both use CPU acceleration for a much smoother effect.
add a comment |
Is there something that can be said about performance. Do both take
advantage of h/w acceleration?
In modern browsers, h/w acceleration occurs for the properties filter, opacity and transform. This is for both CSS Animations and CSS Transitions.
add a comment |
I believe CSS3 animation vs CSS3 transition will give you the answer you want.
Basically below are some takeaways :
- If performance is a concern, then choose CSS3 transition.
- If state is to be maintained after each transition, then choose CSS3 transition.
- If the animation needs to be repeated, choose CSS3 animation. Because it supports animation-iteration-count.
- If a complicated animation is desired. Then CSS3 animation is preferred.
3
#2 and #3 aren't true
– Zach Saucier
Aug 23 '15 at 2:01
I'm not sure how #3 is untrue? It seems a reasonable point to consider, and the animation-iteration-count seems to be a valid property: developer.mozilla.org/en-US/docs/Web/CSS/…
– user4275029
Jul 12 '17 at 13:30
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f20586143%2fcss-animation-vs-transition%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
It looks like you've got a handle on how to do them, just not when to do them.
A transition is an animation, just one that is performed between two distinct states - i.e. a start state and an end state. Like a drawer menu, the start state could be open and the end state could be closed, or vice versa.
If you want to perform something that does not specifically involve a start state and an end state, or you need more fine grain control over the keyframes in a transition, then you've got to use an animation.
5
check out this article too kirupa.com/html5/css3_animations_vs_transitions.htm , it correctly points out that transitions are the way to go when doing javascript interactions.
– Scott Jungwirth
Jun 22 '15 at 17:27
add a comment |
It looks like you've got a handle on how to do them, just not when to do them.
A transition is an animation, just one that is performed between two distinct states - i.e. a start state and an end state. Like a drawer menu, the start state could be open and the end state could be closed, or vice versa.
If you want to perform something that does not specifically involve a start state and an end state, or you need more fine grain control over the keyframes in a transition, then you've got to use an animation.
5
check out this article too kirupa.com/html5/css3_animations_vs_transitions.htm , it correctly points out that transitions are the way to go when doing javascript interactions.
– Scott Jungwirth
Jun 22 '15 at 17:27
add a comment |
It looks like you've got a handle on how to do them, just not when to do them.
A transition is an animation, just one that is performed between two distinct states - i.e. a start state and an end state. Like a drawer menu, the start state could be open and the end state could be closed, or vice versa.
If you want to perform something that does not specifically involve a start state and an end state, or you need more fine grain control over the keyframes in a transition, then you've got to use an animation.
It looks like you've got a handle on how to do them, just not when to do them.
A transition is an animation, just one that is performed between two distinct states - i.e. a start state and an end state. Like a drawer menu, the start state could be open and the end state could be closed, or vice versa.
If you want to perform something that does not specifically involve a start state and an end state, or you need more fine grain control over the keyframes in a transition, then you've got to use an animation.
answered Dec 15 '13 at 1:41
AdamAdam
28k94462
28k94462
5
check out this article too kirupa.com/html5/css3_animations_vs_transitions.htm , it correctly points out that transitions are the way to go when doing javascript interactions.
– Scott Jungwirth
Jun 22 '15 at 17:27
add a comment |
5
check out this article too kirupa.com/html5/css3_animations_vs_transitions.htm , it correctly points out that transitions are the way to go when doing javascript interactions.
– Scott Jungwirth
Jun 22 '15 at 17:27
5
5
check out this article too kirupa.com/html5/css3_animations_vs_transitions.htm , it correctly points out that transitions are the way to go when doing javascript interactions.
– Scott Jungwirth
Jun 22 '15 at 17:27
check out this article too kirupa.com/html5/css3_animations_vs_transitions.htm , it correctly points out that transitions are the way to go when doing javascript interactions.
– Scott Jungwirth
Jun 22 '15 at 17:27
add a comment |
I'll let the definitions speak for themselves (according to Merriam-Webster):
Transition: A movement, development, or evolution from one form, stage, or style to another
Animation: Endowed with life or the qualities of life; full of movement
The names appropriately fit their purposes in CSS
So, the example you gave should use transitions because it is only a change from one state to another
add a comment |
I'll let the definitions speak for themselves (according to Merriam-Webster):
Transition: A movement, development, or evolution from one form, stage, or style to another
Animation: Endowed with life or the qualities of life; full of movement
The names appropriately fit their purposes in CSS
So, the example you gave should use transitions because it is only a change from one state to another
add a comment |
I'll let the definitions speak for themselves (according to Merriam-Webster):
Transition: A movement, development, or evolution from one form, stage, or style to another
Animation: Endowed with life or the qualities of life; full of movement
The names appropriately fit their purposes in CSS
So, the example you gave should use transitions because it is only a change from one state to another
I'll let the definitions speak for themselves (according to Merriam-Webster):
Transition: A movement, development, or evolution from one form, stage, or style to another
Animation: Endowed with life or the qualities of life; full of movement
The names appropriately fit their purposes in CSS
So, the example you gave should use transitions because it is only a change from one state to another
answered Dec 15 '13 at 1:36
Zach SaucierZach Saucier
16.6k74894
16.6k74894
add a comment |
add a comment |
Animation takes a lot more code unless you're using the same transition over and over, in which case an animation would be better.
You can have different effects for sliding in and out without an animation. Just have a different transition on both the original rule and the modified rule:
.two-transitions {
transition: all 50ms linear;
}
.two-transitions:hover {
transition: all 800ms ease-out;
}
Animations are just abstractions of transitions, so if the transition is hardware accelerated, the animation will be. It makes no difference.
Both are very modern.
My rule of thumb is if I use the same transition three times, it should probably be an animation. This is easier to maintain and alter in the future. But if you are only using it once, it is more typing to make the animation and maybe not worth it.
I should also add that animations have keyframes, allowing you to do very complex and controlled progressions, which is kind of amazing.
– paulcpederson
Dec 15 '13 at 6:43
add a comment |
Animation takes a lot more code unless you're using the same transition over and over, in which case an animation would be better.
You can have different effects for sliding in and out without an animation. Just have a different transition on both the original rule and the modified rule:
.two-transitions {
transition: all 50ms linear;
}
.two-transitions:hover {
transition: all 800ms ease-out;
}
Animations are just abstractions of transitions, so if the transition is hardware accelerated, the animation will be. It makes no difference.
Both are very modern.
My rule of thumb is if I use the same transition three times, it should probably be an animation. This is easier to maintain and alter in the future. But if you are only using it once, it is more typing to make the animation and maybe not worth it.
I should also add that animations have keyframes, allowing you to do very complex and controlled progressions, which is kind of amazing.
– paulcpederson
Dec 15 '13 at 6:43
add a comment |
Animation takes a lot more code unless you're using the same transition over and over, in which case an animation would be better.
You can have different effects for sliding in and out without an animation. Just have a different transition on both the original rule and the modified rule:
.two-transitions {
transition: all 50ms linear;
}
.two-transitions:hover {
transition: all 800ms ease-out;
}
Animations are just abstractions of transitions, so if the transition is hardware accelerated, the animation will be. It makes no difference.
Both are very modern.
My rule of thumb is if I use the same transition three times, it should probably be an animation. This is easier to maintain and alter in the future. But if you are only using it once, it is more typing to make the animation and maybe not worth it.
Animation takes a lot more code unless you're using the same transition over and over, in which case an animation would be better.
You can have different effects for sliding in and out without an animation. Just have a different transition on both the original rule and the modified rule:
.two-transitions {
transition: all 50ms linear;
}
.two-transitions:hover {
transition: all 800ms ease-out;
}
Animations are just abstractions of transitions, so if the transition is hardware accelerated, the animation will be. It makes no difference.
Both are very modern.
My rule of thumb is if I use the same transition three times, it should probably be an animation. This is easier to maintain and alter in the future. But if you are only using it once, it is more typing to make the animation and maybe not worth it.
edited Dec 15 '13 at 1:04
m59
36.9k13100118
36.9k13100118
answered Dec 14 '13 at 19:42
paulcpedersonpaulcpederson
487412
487412
I should also add that animations have keyframes, allowing you to do very complex and controlled progressions, which is kind of amazing.
– paulcpederson
Dec 15 '13 at 6:43
add a comment |
I should also add that animations have keyframes, allowing you to do very complex and controlled progressions, which is kind of amazing.
– paulcpederson
Dec 15 '13 at 6:43
I should also add that animations have keyframes, allowing you to do very complex and controlled progressions, which is kind of amazing.
– paulcpederson
Dec 15 '13 at 6:43
I should also add that animations have keyframes, allowing you to do very complex and controlled progressions, which is kind of amazing.
– paulcpederson
Dec 15 '13 at 6:43
add a comment |
Animations are just that - a smooth behavior of set of properties. In other words it specifies what should happen to a set of element's properties. You define an animation and describe how this set of properties should behave during the animation process.
Transitions on the other side specify how a property (or properties) should perform their change. Each change. Setting a new value for certain property, be it with JavaScript or CSS, is always a transition, but by default it is not smooth. By setting transition in the css style you define different (smooth) way to perform these changes.
It can be said that transitions define a default animation that should be performed every time the specified property has changed.
1
I disagree with this definition as both specify how and what
– Zach Saucier
Jul 31 '14 at 2:12
add a comment |
Animations are just that - a smooth behavior of set of properties. In other words it specifies what should happen to a set of element's properties. You define an animation and describe how this set of properties should behave during the animation process.
Transitions on the other side specify how a property (or properties) should perform their change. Each change. Setting a new value for certain property, be it with JavaScript or CSS, is always a transition, but by default it is not smooth. By setting transition in the css style you define different (smooth) way to perform these changes.
It can be said that transitions define a default animation that should be performed every time the specified property has changed.
1
I disagree with this definition as both specify how and what
– Zach Saucier
Jul 31 '14 at 2:12
add a comment |
Animations are just that - a smooth behavior of set of properties. In other words it specifies what should happen to a set of element's properties. You define an animation and describe how this set of properties should behave during the animation process.
Transitions on the other side specify how a property (or properties) should perform their change. Each change. Setting a new value for certain property, be it with JavaScript or CSS, is always a transition, but by default it is not smooth. By setting transition in the css style you define different (smooth) way to perform these changes.
It can be said that transitions define a default animation that should be performed every time the specified property has changed.
Animations are just that - a smooth behavior of set of properties. In other words it specifies what should happen to a set of element's properties. You define an animation and describe how this set of properties should behave during the animation process.
Transitions on the other side specify how a property (or properties) should perform their change. Each change. Setting a new value for certain property, be it with JavaScript or CSS, is always a transition, but by default it is not smooth. By setting transition in the css style you define different (smooth) way to perform these changes.
It can be said that transitions define a default animation that should be performed every time the specified property has changed.
answered Mar 11 '14 at 21:23
Jonan GeorgievJonan Georgiev
461510
461510
1
I disagree with this definition as both specify how and what
– Zach Saucier
Jul 31 '14 at 2:12
add a comment |
1
I disagree with this definition as both specify how and what
– Zach Saucier
Jul 31 '14 at 2:12
1
1
I disagree with this definition as both specify how and what
– Zach Saucier
Jul 31 '14 at 2:12
I disagree with this definition as both specify how and what
– Zach Saucier
Jul 31 '14 at 2:12
add a comment |
A shorter answer, straight on point:
Transition:
- Needs a triggering element (:hover, :focus etc.)
- Only 2 animation states (start and end)
- Used for simpler animations (buttons, dropdown menus and so on)
- Easier to create but not so many animation/effect possibilities
Animation @keyframes:
- It can be used for endless animations
- Can set more than 2 states
- No boundaries
Both use CPU acceleration for a much smoother effect.
add a comment |
A shorter answer, straight on point:
Transition:
- Needs a triggering element (:hover, :focus etc.)
- Only 2 animation states (start and end)
- Used for simpler animations (buttons, dropdown menus and so on)
- Easier to create but not so many animation/effect possibilities
Animation @keyframes:
- It can be used for endless animations
- Can set more than 2 states
- No boundaries
Both use CPU acceleration for a much smoother effect.
add a comment |
A shorter answer, straight on point:
Transition:
- Needs a triggering element (:hover, :focus etc.)
- Only 2 animation states (start and end)
- Used for simpler animations (buttons, dropdown menus and so on)
- Easier to create but not so many animation/effect possibilities
Animation @keyframes:
- It can be used for endless animations
- Can set more than 2 states
- No boundaries
Both use CPU acceleration for a much smoother effect.
A shorter answer, straight on point:
Transition:
- Needs a triggering element (:hover, :focus etc.)
- Only 2 animation states (start and end)
- Used for simpler animations (buttons, dropdown menus and so on)
- Easier to create but not so many animation/effect possibilities
Animation @keyframes:
- It can be used for endless animations
- Can set more than 2 states
- No boundaries
Both use CPU acceleration for a much smoother effect.
edited Jan 23 at 8:37
Pang
6,9161664102
6,9161664102
answered Jan 14 at 11:17
GrecAGrecA
214
214
add a comment |
add a comment |
Is there something that can be said about performance. Do both take
advantage of h/w acceleration?
In modern browsers, h/w acceleration occurs for the properties filter, opacity and transform. This is for both CSS Animations and CSS Transitions.
add a comment |
Is there something that can be said about performance. Do both take
advantage of h/w acceleration?
In modern browsers, h/w acceleration occurs for the properties filter, opacity and transform. This is for both CSS Animations and CSS Transitions.
add a comment |
Is there something that can be said about performance. Do both take
advantage of h/w acceleration?
In modern browsers, h/w acceleration occurs for the properties filter, opacity and transform. This is for both CSS Animations and CSS Transitions.
Is there something that can be said about performance. Do both take
advantage of h/w acceleration?
In modern browsers, h/w acceleration occurs for the properties filter, opacity and transform. This is for both CSS Animations and CSS Transitions.
answered Nov 22 '18 at 6:01
Eric WilligersEric Willigers
93968
93968
add a comment |
add a comment |
I believe CSS3 animation vs CSS3 transition will give you the answer you want.
Basically below are some takeaways :
- If performance is a concern, then choose CSS3 transition.
- If state is to be maintained after each transition, then choose CSS3 transition.
- If the animation needs to be repeated, choose CSS3 animation. Because it supports animation-iteration-count.
- If a complicated animation is desired. Then CSS3 animation is preferred.
3
#2 and #3 aren't true
– Zach Saucier
Aug 23 '15 at 2:01
I'm not sure how #3 is untrue? It seems a reasonable point to consider, and the animation-iteration-count seems to be a valid property: developer.mozilla.org/en-US/docs/Web/CSS/…
– user4275029
Jul 12 '17 at 13:30
add a comment |
I believe CSS3 animation vs CSS3 transition will give you the answer you want.
Basically below are some takeaways :
- If performance is a concern, then choose CSS3 transition.
- If state is to be maintained after each transition, then choose CSS3 transition.
- If the animation needs to be repeated, choose CSS3 animation. Because it supports animation-iteration-count.
- If a complicated animation is desired. Then CSS3 animation is preferred.
3
#2 and #3 aren't true
– Zach Saucier
Aug 23 '15 at 2:01
I'm not sure how #3 is untrue? It seems a reasonable point to consider, and the animation-iteration-count seems to be a valid property: developer.mozilla.org/en-US/docs/Web/CSS/…
– user4275029
Jul 12 '17 at 13:30
add a comment |
I believe CSS3 animation vs CSS3 transition will give you the answer you want.
Basically below are some takeaways :
- If performance is a concern, then choose CSS3 transition.
- If state is to be maintained after each transition, then choose CSS3 transition.
- If the animation needs to be repeated, choose CSS3 animation. Because it supports animation-iteration-count.
- If a complicated animation is desired. Then CSS3 animation is preferred.
I believe CSS3 animation vs CSS3 transition will give you the answer you want.
Basically below are some takeaways :
- If performance is a concern, then choose CSS3 transition.
- If state is to be maintained after each transition, then choose CSS3 transition.
- If the animation needs to be repeated, choose CSS3 animation. Because it supports animation-iteration-count.
- If a complicated animation is desired. Then CSS3 animation is preferred.
answered Jun 17 '15 at 15:35
PixelsTechPixelsTech
1,82812327
1,82812327
3
#2 and #3 aren't true
– Zach Saucier
Aug 23 '15 at 2:01
I'm not sure how #3 is untrue? It seems a reasonable point to consider, and the animation-iteration-count seems to be a valid property: developer.mozilla.org/en-US/docs/Web/CSS/…
– user4275029
Jul 12 '17 at 13:30
add a comment |
3
#2 and #3 aren't true
– Zach Saucier
Aug 23 '15 at 2:01
I'm not sure how #3 is untrue? It seems a reasonable point to consider, and the animation-iteration-count seems to be a valid property: developer.mozilla.org/en-US/docs/Web/CSS/…
– user4275029
Jul 12 '17 at 13:30
3
3
#2 and #3 aren't true
– Zach Saucier
Aug 23 '15 at 2:01
#2 and #3 aren't true
– Zach Saucier
Aug 23 '15 at 2:01
I'm not sure how #3 is untrue? It seems a reasonable point to consider, and the animation-iteration-count seems to be a valid property: developer.mozilla.org/en-US/docs/Web/CSS/…
– user4275029
Jul 12 '17 at 13:30
I'm not sure how #3 is untrue? It seems a reasonable point to consider, and the animation-iteration-count seems to be a valid property: developer.mozilla.org/en-US/docs/Web/CSS/…
– user4275029
Jul 12 '17 at 13:30
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f20586143%2fcss-animation-vs-transition%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown