Method: 1. Use the animation attribute to bind animation to the element; 2. Use the "@keyframes name {100%{transform:rotate (rotation angle) translate (displacement distance);}}" statement to set the element's Action keyframes for rotation and displacement to achieve rotation and displacement animation effects.
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
How to implement rotation and displacement animation in css3
In css, you can use the animation attribute to bind rotation and displacement animation to elements.
Use the @keyframes rule to set the animation action keyframes of the element, use the transform attribute with the rotate() function to set the element rotation action, and use the transform attribute with the translate() function to set the element displacement action.
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> .div1{ width:100px; height:100px; background:pink; border-radius:50%; margin:0 auto; animation:fadenum 5s; } @keyframes fadenum{ 0%{transform:rotate(360deg) translateX(-200px);} } </style> </head> <body> <div class="div1">这是一个旋转加位移的效果</div> </body> </html>
Output result:
##(Learning video sharing:css video tutorial)
The above is the detailed content of How to implement rotation and displacement animation in css3. For more information, please follow other related articles on the PHP Chinese website!