Home >Web Front-end >CSS Tutorial >How to achieve the rotation effect of moving the mouse up in css

How to achieve the rotation effect of moving the mouse up in css

青灯夜游
青灯夜游Original
2022-01-20 15:53:355604browse

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.

How to achieve the rotation effect of moving the mouse up in css

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>

How to achieve the rotation effect of moving the mouse up in css

(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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn