Home  >  Article  >  Web Front-end  >  What are the properties in css that can achieve rotation effects?

What are the properties in css that can achieve rotation effects?

青灯夜游
青灯夜游Original
2021-04-06 17:33:215141browse

The attribute that can achieve the rotation effect is "transform", which needs to be used together with functions such as rotate(), rotate3d(), rotateX(), rotateY(). The transform attribute is used to apply a 2D or 3D transformation to an element, allowing it to be rotated, scaled, moved or tilted.

What are the properties in css that can achieve rotation effects?

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

The attribute in css that can achieve rotation effect is "transform".

The transform property applies a 2D or 3D transformation to an element. This property allows us to rotate, scale, move or tilt the element.

The transform attribute can realize the attribute value of rotation:

  • rotate(angle) defines 2D rotation and specifies the angle in the parameters.

  • rotate3d(x,y,z,angle) Define 3D rotation.

  • rotateX(angle) Defines a 3D rotation along the X-axis.

  • rotateY(angle) Defines 3D rotation along the Y axis.

  • rotateZ(angle) Defines 3D rotation along the Z axis.

Example:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
    div,img,body{
        margin: 0;
        padding: 0;
    }
    img.touxiang:hover{
        transform: rotate(180deg);
        -webkit-transform: rotate(180deg);
        -moz-transform: rotate(180deg);
        -o-transform: rotate(180deg);
        -ms-transform: rotate(180deg);
    }
    img.touxiang{
        margin: 0 auto;
        display: block;
        transition: all 0.2s ease-in-out;
        -webkit-transition: all 0.2s ease-in-out;
        -moz-transition: all 0.2s ease-in-out;
        -o-transition: all 0.2s ease-in-out;
        border-radius:100%;
    }
</style>
</head>
<body><br><br><br><br>
    <img src="touxiang.jpg" alt=""/>
</body>
</html>

Rendering:

What are the properties in css that can achieve rotation effects?

(Learning video sharing: css video tutorial )

The above is the detailed content of What are the properties in css that can achieve rotation effects?. 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