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
1. Introduction In the past, if you wanted to emp...
If you forget your MySQL login password, the solu...
This article example shares the specific code of ...
The previous article was a simple review of the B...
Using fonts on the Web is both a fundamental skill...
Table of contents Create a global shared content ...
Table of contents 1. Build the Vue environment 2....
In my previous article, I said that the optimizat...
Table of contents background What is the Metavers...
Detailed explanation of Linux LVM logical volume ...
Table of contents 1. Introduction to the connecti...
Table of contents 1. What is a prototype? 1.1 Fun...
This article mainly introduces why v-if and v-for...
Neo4j (one of the Nosql) is a high-performance gr...
This article shares the specific code of JavaScri...