Method: 1. Use "@keyframes animation name {100% {transform:rotate(angle)}" to create a rotation animation; 2. Use "element:hover{animation: animation name time linear infinite}" to set Triggers animation when mouse moves over element.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css to achieve the rotation effect when the mouse moves up
The rotation effect can be created using the animation attribute and the "@keyframes" rule Animation implementation.
When the mouse moves over the element, the :hover
selector is required to trigger the rotation animation. (The:hover selector is used to select the element on which the mouse pointer is floating and set the style.)
Implementation code:
<!DOCTYPE html> <html> <head> <style> div { width: 100px; height: 100px; background-color: red; margin: 50px auto; } div:hover { animation: mymove 1s linear infinite; } @keyframes mymove { 100% { transform: rotate(360deg); } } @-webkit-keyframes mymove {/* Safari and Chrome */ 100% { transform: rotate(360deg); } } </style> </head> <body> <div class="box"></div> </body> </html>
(Learning video sharing: css video tutorial)
The above is the detailed content of How to achieve the rotation effect of moving the mouse up in css. For more information, please follow other related articles on the PHP Chinese website!