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
Table of contents 1. Component Introduction 2. So...
When people are working on a backend management s...
Table of contents 1. Replace the apply method, ge...
This article shares the specific code of jQuery t...
Table of contents Business requirements: Solution...
After installing VMware Tools, ① text can be copi...
Dynamically implement a simple secondary menu Whe...
Table of contents 1. Introduction: 2. Docker: 1 C...
Use JS timer to make an element to make a method ...
Windows: Support NTFS, FAT Linux supports file fo...
1.17.9 More delicious, really Nginx download addr...
<br />Question: Why is it not recommended to...
I was in a meeting when a colleague called to rep...
The picture is used as the background and the lin...
You may encounter the following problems when ins...