The difference between CSS3 animation and JS animation JS implements frame animation
transition Transition is a simple animation attribute, which can be regarded as a simplified version of animation. It is usually used with event triggering and is simple and easy to use. Transition property values
Transition Features Transitions need to be triggered by events [such as adding a hover pseudo-class]. They cannot happen automatically once when the page is loaded, and they cannot happen repeatedly unless they are triggered repeatedly. There are only two states: start and end. A transition rule can only define one attribute. <body> <div ></div> </body> <style> .box { height: 100px; width: 100px; background-color: lightpink; transition: width 1s 0.5s ease-in-out; } .box:hover { width: 200px; } </style> The effect is as follows You can also write transition in .box:hover { width: 200px; transition: width 1s 0.5s ease-in-out; } In fact, it is also possible to write on hover, but when I move out of the element, the element width is immediately restored without any transition! animation Animation property values
<body> <div ></div> </body> <style> .box { height: 200px; width: 200px; animation: 3s type forwards alternate infinite; animation-play-state: running; } .box:hover { animation-play-state: paused; } @keyframes type { from { background: yellowgreen } 50% { background: yellow } to { background: aquamarine } } </style> Pause when the mouse moves in, and continue changing color when the mouse moves out transform First of all, it should be noted that the transform attribute is a static attribute. Once it is written into the style, it will be directly displayed and will not appear in the animation process. By using the transform attribute, elements can be moved (translate), scaled (scale), rotated (rotate), and flipped (skew). For more detailed parameters, please refer to the CSS3 transform attribute. Summarize
The above is the detailed content of the difference between animation and transition. For more information about animation and transition, please pay attention to other related articles on 123WORDPRESS.COM! |
<<: Summary of experience in using div box model
>>: Introduction to deploying selenium crawler program under Linux system
The key is that the local server does not have wr...
Table of contents Preface Understanding a stack a...
The content involved in Web front-end development...
This article shares the specific code of js to ac...
I have encountered many centering problems recent...
Label display mode (important) div and span tags ...
Table of contents 1. Problem Description 2. Probl...
Table of contents Preface 1. scp usage 2. Use sft...
When you browse many websites, you will find that ...
This article shares the specific code for impleme...
Detailed explanation of the misplacement of the in...
This article shares the specific code for using j...
Union is a union operation on the data, excluding...
Programmers must deal with MySQL a lot, and it ca...
About Nginx, a high-performance, lightweight web ...