How to achieve counterclockwise rotation effect on mouse hover elements in css

WBOY
Release: 2021-11-30 18:30:59
Original
4280 people have browsed it

In CSS, you can use the ":hover" pseudo-class selector and transform attribute to achieve the counterclockwise rotation effect of mouse-hovered elements. The syntax is "element:hover{transform:rotateZ (rotation angle);}" .

How to achieve counterclockwise rotation effect on mouse hover elements in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

How to achieve the counterclockwise rotation effect of mouse hover elements in css

You can use the ":hover" pseudo-class selector and transform in css The attribute achieves the effect of counterclockwise rotation when the mouse is rolled over the image. The transform property applies a 2D or 3D transformation to an element. This property allows us to rotate, scale, move or tilt the element.

Let’s take a look at an example. The example is as follows:

<html>
<head> 
<style>
.keleyi {
width: 220px;
height: 220px;
margin: 0 auto;
background: no-repeat url("1118.02.png") left top;
-webkit-background-size: 220px 220px;
background-size: 220px 220px;
-webkit-border-radius: 110px;
border-radius: 110px;
-webkit-transition: -webkit-transform 2s ease-out;
}
.keleyi:hover {
-webkit-transform: rotateZ(-360deg);
transform: rotateZ(-360deg);
}
</style>
</head>
<body>
<div class="keleyi"></div>
</body>
</html>
Copy after login

Output result:

How to achieve counterclockwise rotation effect on mouse hover elements in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to achieve counterclockwise rotation effect on mouse hover elements in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template