In css3, you can use @keyframes rules, animation and transform attributes to define rotation animation; animation attributes are used to bind element animation effects, @keyframes rules are used to set element animation actions, and transform attributes are used to set elements rotation style.
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
With the @keyframes rule, you can create animations.
The principle of creating animation is to gradually change one set of CSS styles into another set of styles. The
animation property is a shorthand property for setting six animation properties:
animation: name duration timing-function delay iteration-count direction;
The transform property applies a 2D or 3D transformation to an element. This property allows us to rotate, scale, move or tilt the element.
otate(angle) defines 2D rotation, specifying the angle in the parameter.
The example is as follows:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> div{ width:100px; height:100px; background-color:pink; animation:fadenum 5s infinite; } @keyframes fadenum{ 100%{transform:rotate(360deg);} } </style> </head> <body> <div></div> </body> </html>
Output result:
(Learning video sharing: css video tutorial)
The above is the detailed content of What defines rotation animation in css3 animation. For more information, please follow other related articles on the PHP Chinese website!