Home > Web Front-end > CSS Tutorial > How to set the image to rotate in css

How to set the image to rotate in css

王林
Release: 2020-11-30 14:15:44
Original
7927 people have browsed it

How to set the image to rotate continuously in css: You can set it by using the animation attribute and transform attribute, such as [-webkit-transform: rotate(360deg); animation: rotation;].

How to set the image to rotate in css

The operating environment of this tutorial: Windows 10 system, CSS3 version. This method is suitable for all brands of computers.

(Learning video sharing: css video tutorial)

How to set the image to rotate continuously in css:

Related attributes :

animation animation attribute

animation: name duration timing-function delay iteration-count direction fill-mode play-state;
Copy after login

Attribute value:

  • animation-name Specifies the name of the keyframe to be bound to the selector

  • animation-duration Specifies how many seconds or milliseconds the animation takes to complete

  • ##animation-timing-function Sets how the animation will complete a cycle

  • animation-delay Set the delay interval before the animation starts.

  • animation-iteration-count Defines the number of times the animation is played.

  • animation-direction Specifies whether the animation should be played in reverse in turn.

  • animation-fill-mode Specifies the style to be applied to the element when the animation is not playing (when the animation is completed, or when there is a delay before the animation starts playing).

  • animation-play-state Specifies whether the animation is running or paused.​

  • #initial Set the property to its default value.

  • inherit Inherit attributes from the parent element.​

TheTransform property applies a 2D or 3D transformation to an element. This property allows you to rotate, scale, move, tilt, etc. the element.

transform: none|transform-functions;
Copy after login

Attribute value:

  • none The definition is not converted.

  • matrix(n,n,n,n,n,n) Defines a 2D transformation, using a matrix of six values.

  • matrix3d(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n) defines 3D transformation, Use a 4x4 matrix of 16 values.

  • translate(x,y) Define 2D transformation.

  • translate3d(x,y,z) Define 3D transformation.

Code implementation:

html code:

<div class="demo">
    <img  class="an img" src="/test/img/2.png"    style="max-width:90%"  style="max-width:90%"/ alt="How to set the image to rotate in css" >
</div>
Copy after login

Rotation code:

.demo{
   text-align: center;
    margin-top: 100px;
}
@-webkit-keyframes rotation{
    from {-webkit-transform: rotate(0deg);}
    to {-webkit-transform: rotate(360deg);}
}
.an{
    -webkit-transform: rotate(360deg);
    animation: rotation 3s linear infinite;
    -moz-animation: rotation 3s linear infinite;
    -webkit-animation: rotation 3s linear infinite;
    -o-animation: rotation 3s linear infinite;
}
.img{border-radius: 250px;}
Copy after login
Realization effect:

How to set the image to rotate in css

Related recommendations:

CSS tutorial

The above is the detailed content of How to set the image to rotate in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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